GeezerVison is showing github.com — HTTP2 compatibility layer issues with invalid streams · Issue #29529 · nodejs/node
HTTP2 compatibility layer issues with invalid streams #29529Labels httpIssues and PRs related to the http subsystem.http2Issues and PRs related to the http2 subsystem.streamIssues and PRs related to Node.js streams. Descriptionhttps://pastebin.com/LAfzJnQf
Node 12.10, using ssl. The whole code handles both http1 and http2 exactly the same, yet this only happens for ssl using http2. Activitymscdex commented on Sep 11, 2019 It's better to post the details here instead of a link in case the link ever dies.
Here's the text from the link:
c/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:132
throw err;
^
Error [ERR_HTTP2_INVALID_STREAM]: The stream has been destroyed
at Http2ServerResponse.write (internal/http2/compat.js:637:19)
at GridFSBucketReadStream.<anonymous> (/home/LynxChan/src/be/engine/gridFsHandler.js:304:9)
at GridFSBucketReadStream.emit (events.js:209:13)
at addChunk (_stream_readable.js:305:12)
at readableAddChunk (_stream_readable.js:286:11)
at GridFSBucketReadStream.Readable.push (_stream_readable.js:220:10)
at /home/LynxChan/src/be/node_modules/mongodb/lib/gridfs-stream/download.js:250:11
at /home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:414:17
at executeCallback (/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:406:9)
at handleCallback (/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:128:55)
Server worker 1 crashed.
Issues were found with the templates.
Page boardsPage
Error, missing element linkOverboard
Error, missing element linkSfwOver
Worker 2 booted at Wed, 11 Sep 2019 18:14:54 GMT
/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:132
throw err;
^
Error [ERR_HTTP2_INVALID_STREAM]: The stream has been destroyed
at Http2ServerResponse.write (internal/http2/compat.js:637:19)
at GridFSBucketReadStream.<anonymous> (/home/LynxChan/src/be/engine/gridFsHandler.js:304:9)
at GridFSBucketReadStream.emit (events.js:209:13)
at addChunk (_stream_readable.js:305:12)
at readableAddChunk (_stream_readable.js:286:11)
at GridFSBucketReadStream.Readable.push (_stream_readable.js:220:10)
at /home/LynxChan/src/be/node_modules/mongodb/lib/gridfs-stream/download.js:250:11
at /home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:414:17
at executeCallback (/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:406:9)
at handleCallback (/home/LynxChan/src/be/node_modules/mongodb/lib/utils.js:128:55)
Server worker 2 crashed.
jasnell commented on Sep 11, 2019 Hmmm yeah, the http2 streams are handling things a bit more strict than the http1 code. We likely need to relax that in the compatibility layer. /cc @nodejs/http2 @apapirovski jasnell commented on Sep 11, 2019 Actually, taking the confirmed bug label back off for the time being, want to test a bit more. @StephenLynx can you provide a simple reproduceable test case we can use that demonstrates the problem StephenLynx commented on Sep 12, 2019 @jasnell Nope. All I got is a report from a person running my software. The information I got is that it happens every now and then after ssl is enabled. Is not the first person to report something similar. My software uses http2 for ssl, I don't run ssl on my own site. Most people end up letting nginx handle ssl, so is not often that people run into issues.
My software is gitgud.io/LynxChan/LynxChan. The part that touches http2 is https://gitgud.io/LynxChan/LynxChan/blob/2.2.x/src/be/workerBoot.js#L78 sogaani commented on Sep 12, 2019 This issue might be the same I reported here(second possible reason) and I wrote a reproduceable test case. StephenLynx commented on Sep 14, 2019 @jasnell can you put back the confirmed bug tag? sogaani just posted a reproduceable test case. sogaani commented on Sep 15, 2019 @StephenLynx
To be sure that the issue you reported and mine are the same, could you check if your software returns 304 or 204 when errors happen? StephenLynx commented on Sep 15, 2019 @sogaani no, my software just crashes. I pretty much implemented a framework inside the software and I don't take in account the exception thrown by the compatibility layer, so it just crashes. zandaqo commented on Sep 16, 2019 I also have an issue with 12.10 when I use HTTP2+SSL in production: every now and then the POST request's stream fails to fire end event and just hangs there waiting for more data. It happens unpredictably, no errors are thrown, so I cannot pin point the issue at the moment, but I do know that the stream fires data events and receive all the data but doesn't fire end, error, or frameError events to finish the request. As a workaround for now I just check in data if the received length is equal to the expected length and end the request myself. Reacted by Jacob Page and Ali Rahbari sogaani commented on Sep 17, 2019 @StephenLynx Then I'm not sure your bug and reproduceable test are the same as mine.
Before exception,if your software calls res.writeHead(304) or res.writeHead(204), it might be the same. StephenLynx commented on Sep 17, 2019 @sogaani No, the cause of the crash is a res.write with binary data. StephenLynx commented on Oct 1, 2019 DullReferenceException commented on Jan 10, 2020
I also have an issue with 12.10 when I use HTTP2+SSL in production: every now and then the POST request's stream fails to fire end event and just hangs there waiting for more data. It happens unpredictably, no errors are thrown, so I cannot pin point the issue at the moment, but I do know that the stream fires data events and receive all the data but doesn't fire end, error, or frameError events to finish the request. As a workaround for now I just check in data if the received length is equal to the expected length and end the request myself.
@zandaqo: I think your message got lost in this issue; it sounds like a different problem than what was originally posted. FWIW, we're having what I think is the exact same issue. I'm still searching to see if there's a different issue focusing on this problem. If you know of where that is, it'd be great to see your workaround. zandaqo commented on Jan 12, 2020 @DullReferenceException I'm glad you brought it up, I checked recently and the issue is still present in Node 13. As I wrote before, my workaround is terminating requests when the received data length equals the Content-Length header. For raw-body it results in appending a single line to onData function used as a callback for data events:
function onData(chunk) {
if (complete) return;
received += chunk.length;
if (limit !== null && received > limit) {
done(createError(413, 'request entity too large', {
limit,
received,
type: 'entity.too.large',
}));
} else if (decoder) {
buffer += decoder.write(chunk);
} else {
buffer.push(chunk);
}
if (received === length) onEnd();
}
MetadataMetadatahttpIssues and PRs related to the http subsystem.http2Issues and PRs related to the http2 subsystem.streamIssues and PRs related to Node.js streams. DevelopmentNo branches or pull requestsIssue actions
|