-
Notifications
You must be signed in to change notification settings - Fork 559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: dont crash on invalid brotli payload #3620
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an error listener should still be added onto pipeline(...)... this only fixes the one case
#3616 (comment)
@KhafraDev better? |
lib/web/fetch/index.js
Outdated
body: streams === undefined | ||
? this.body.on('error', noop) | ||
: pipeline(streams, noop).on('error', noop) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just hiding a bug somewhere else
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about now?
@KhafraDev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are quite a few unnecessary changes that make this section harder to read
|
||
this.body = new Readable({ read: resume }) | ||
|
||
const decoders = [] | ||
/** @type {[src: import('node:stream').Readable, ...target: import('node:stream').Writable[]]} */ | ||
let streams |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let streams | |
const streams = [] |
|
||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding | ||
if (codings.length !== 0 && request.method !== 'HEAD' && request.method !== 'CONNECT' && !nullBodyStatus.includes(status) && !willFollow) { | ||
streams = [this.body] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
streams = [this.body] |
decoders.length = 0 | ||
// If the server sends the payload with a coding which his not | ||
// supported, the body will be passed through without decoding. | ||
streams = undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
streams = undefined | |
streams.length = 0 |
body: decoders.length | ||
? pipeline(this.body, ...decoders, noop) | ||
: this.body.on('error', noop) | ||
body: streams === undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
body: streams === undefined | |
body: streams.length === 0 |
: this.body.on('error', noop) | ||
body: streams === undefined | ||
? this.body.on('error', onError) | ||
: pipeline(streams, callback).on('error', onError) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
: pipeline(streams, callback).on('error', onError) | |
: pipeline(this.body, ...streams, callback).on('error', onError) |
Tbh i dont like the suggested changes. So I retract this PR. No bad feelings ;). |
I will work on it tomorrow. |
Fixes #3616 by setting the corresponding flags for brotli like we did for gzip in #2126
https://nodejs.org/api/zlib.html#compressing-http-requests-and-responses
But why does deflate not need those flags?