Closed ikreymer closed 1 month ago
@ronag it seems like pipeline isn't forwarding the error here? This fixes it:
diff --git a/lib/web/fetch/index.js b/lib/web/fetch/index.js
index 435eafdf..9a26977e 100644
--- a/lib/web/fetch/index.js
+++ b/lib/web/fetch/index.js
@@ -2153,7 +2153,7 @@ async function httpNetworkFetch (
} else if (coding === 'deflate') {
decoders.push(createInflate())
} else if (coding === 'br') {
- decoders.push(zlib.createBrotliDecompress())
+ decoders.push(zlib.createBrotliDecompress().on('error', noop))
} else {
decoders.length = 0
break
import { pipeline, Readable } from 'node:stream'
import { createBrotliDecompress } from 'node:zlib'
pipeline(new Readable({
read () {
this.push(null)
}
}), createBrotliDecompress(), () => {})
reproducible without fetch
That example is incorrect as pipeline
will return a readable stream:
pipeline(new Readable({
read () {
this.push(null)
}
}), createBrotliDecompress(), () => {}).on('error, () => {})
it seems like pipeline isn't forwarding the error here? This fixes it:
As far as I can tell it is forwarding it, it's just not handled...
Seems to me related to either fetch or WebStreams.
As far as I can tell it is forwarding it, it's just not handled...
Shouldn't the error be passed to the callback (last parameter)? Maybe I'm misunderstanding it?
This example is what I'm confused about: https://nodejs.org/api/stream.html#streampipelinestreams-callback
As far as I can tell it is forwarding it, it's just not handled...
Shouldn't the error be passed to the callback (last parameter)? Maybe I'm misunderstanding it?
This example is what I'm confused about: https://nodejs.org/api/stream.html#streampipelinestreams-callback
Not if the last stream passed is readable.
provided PR #3620
Version
22.6.0, 20.9.0, 20.17.0
Platform
No response
Subsystem
No response
What steps will reproduce the bug?
An empty response with
Content-Encoding: br
results in an error if the response is canceled, not consumed, consumed by a stream.This can be reproduced with a server:
and then a client calling:
Although
done
will be printed, an exception will be thrown afterwards:How often does it reproduce? Is there a required condition?
This happens whenever the stream is not immediately consumed
The following will cause a crash:
The following will NOT cause a crash, because the body is immediately consumed:
What is the expected behavior? Why is that the expected behavior?
fetch() should not a cause an unhandled error that crashes node, even if the response body is never consumed, especially since it is empty. This is the behavior with other compression types, such as
Content-Encoding: gzip
.What do you see instead?
fetch() causes node to crash due to an unhandled error event from BrotliDecompress
Additional information
No response