-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Open
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.http2Issues or PRs related to the http2 subsystem.Issues or PRs related to the http2 subsystem.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.
Description
I noticed this from an assertion i production. A http2 response can become writableEnded and writableFinished without the user ever calling response.end(). I believe there is some special logic for HEAD requests that causes this behavior.
I think this is suboptimal from a streams perspective but could still be considered ok behavior. I don't think "self ending" streams are a good idea. However, from a http1 compat perspective it does differ in behavior from http1 response which can cause unexpected problems if one assumes that a http2 compat response behaves exactly like a http1 response.
I basically had something like this in our code:
function onUpstreamComplete (trailers) {
const { res } = this
// Ensure we don't have a bug somewhere "corrupting" state by prematurely ending or destroying response.
assert(!res.destroyed)
assert(!res.writableEnded)
assert(!res.writableFinished)
writeTrailers(res, trailers)
res.end()
}
Metadata
Metadata
Assignees
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.http2Issues or PRs related to the http2 subsystem.Issues or PRs related to the http2 subsystem.streamIssues and PRs related to the stream subsystem.Issues and PRs related to the stream subsystem.