-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
Closed
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
Version
v17.1.0 / master
Platform
mac and linux
Subsystem
stream, http
What steps will reproduce the bug?
Run the following code:
'use strict'
const { finished } = require('stream')
const { createReadStream } = require('fs')
const { createServer, request } = require('http')
const server = createServer(function (req, res) {
createReadStream(__filename).pipe(res)
finished(res, function (err) {
if (err) {
throw err
}
})
}).listen(3000, function () {
request({ method: 'GET', port: '3000' }, function (res) {
console.log('response received')
res.pipe(process.stdout)
server.close()
}).end()
})
Currently it throws. It did not throw in v16, and it should not really throw at all.
Thrown error:
/home/matteo/repositories/node/bug.js:12
throw err
^
Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
at new NodeError (node:internal/errors:371:5)
at ServerResponse.onclose (node:internal/streams/end-of-stream:122:30)
at ServerResponse.emit (node:events:402:35)
at emitCloseNT (node:_http_server:845:10)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'ERR_STREAM_PREMATURE_CLOSE'
}
Metadata
Metadata
Assignees
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.