-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Closed
Labels
to triageWaiting to be triaged by a member of the teamWaiting to be triaged by a member of the team
Description
Describe the bug
Lines 625 to 643 in e36062c
| switch (encoding) { | |
| case "br": | |
| res.writeHead(200, { "content-encoding": "br" }); | |
| readStream.pipe(createBrotliCompress()).pipe(res); | |
| pipeline(readStream, createBrotliCompress(), res, onError); | |
| break; | |
| case "gzip": | |
| res.writeHead(200, { "content-encoding": "gzip" }); | |
| pipeline(readStream, createGzip(), res, onError); | |
| break; | |
| case "deflate": | |
| res.writeHead(200, { "content-encoding": "deflate" }); | |
| pipeline(readStream, createDeflate(), res, onError); | |
| break; | |
| default: | |
| res.writeHead(200); | |
| pipeline(readStream, res, onError); | |
| } | |
| } |
While serving assets and encoding is 'br' there is a race condition, seeing code we are piping 2 times. Should be only 1 time
readStream.pipe(createBrotliCompress()).pipe(res);
pipeline(readStream, createBrotliCompress(), res, onError);below is the error I'm getting below error when serving /socket.io.min.js
error Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
at new NodeError (node:internal/errors:393:5)
at ServerResponse.<anonymous> (node:internal/streams/pipeline:352:14)
at ServerResponse.emit (node:events:525:35)
at ServerResponse.emit (node:domain:489:12)
at emitCloseNT (node:_http_server:961:10)
at processTicksAndRejections (node:internal/process/task_queues:81:21) {
code: 'ERR_STREAM_PREMATURE_CLOSE'
}
To Reproduce
When browser uses br as accept encoding to download files added in <script src="">
Getting the above error.
Expected behavior
A clear and concise description of what you expected to happen.
Platform:
- Device: [e.g. Samsung S8]
- OS: [e.g. Android 9.2]
Metadata
Metadata
Assignees
Labels
to triageWaiting to be triaged by a member of the teamWaiting to be triaged by a member of the team