-
Notifications
You must be signed in to change notification settings - Fork 30k
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
HTTP2 compatibility layer issues with invalid streams #29529
Comments
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:
|
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 |
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 |
@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. |
This issue might be the same I reported here(second possible reason) and I wrote a reproduceable test case. |
@jasnell can you put back the confirmed bug tag? sogaani just posted a reproduceable test case. |
@StephenLynx |
@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. |
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 |
@StephenLynx Then I'm not sure your bug and reproduceable test are the same as mine. |
@sogaani No, the cause of the crash is a res.write with binary data. |
So, @jasnell what's up? |
Would it not make sense to make it behave equal to http1 if it's a compability layer to begin with? 😕 (Having some errors with the current behavior as well) |
Any news, @jasnell ? |
Btw, I tried (and failed) to reproduce this with a minimal setup/unit test so far, could you try to set something up? @StephenLynx |
@addaleax I don't know who else to mention here. What's the deal with this issue that no one seems to talk about? It's been confirmed it's just the compatibility layer being too strict. Is this being discussed? Did people just forget? Are people just too busy to do anything about it? |
@StephenLynx: This looks more like a bug in http/1 that doesn't error if Though http/2 compat should error with |
@ronag that would be a very, very, very, very old bug. Because I have used http1 the same way for almost 5 years without issues. I have a feeling if http1 didn't just ignore w/e error it is ignoring, it would be chaotic for developers. I never manually destroy the request when this error triggers, whatever happens, happens inside node's code. Are you sure you are correct? |
Well, it might not have been a bug in the past but there has been breaking changes in the Node API over the years which might make some consider this a bug.
This would not be a problem if there was a Whether this should be fixed or not is I guess up for debate. My personal opinion is to keep things as consistent as possible with the "expected" behaviour of streams. There are also other discrepancies that we should/might address that might be of interest #29829. I'm probably a bit more strict on the "correctness" vs "breaking" topic than most. @mcollina @jasnell What's your take here? Should we relax http/2 compat to match http/1, or tighten http/1 to match streams? |
@Trott: I would recommend http and stream labels on this issue. |
@ronag I do have a callback on the error listener. |
Also, as a user just expressing what I would like to have when using node as a tool, I'd REALLY love the http2/compat to be as permissive as http1 if the issue is http1 not strictly following specs. |
@StephenLynx You need an I don't think the server |
Also, as a side note, I'm not 100% this discrepancy is the issue. If the response is destroyed both in the http/1 and http/2 compat case, then http/1 will be permissive and that's why you observe different behaviors. If the problem is that the response is destroyed in the http/2 compat but not in the http/1 case then it's something else. It's hard to tell which one of these is the actual root cause. |
I see. I'll add the error listener on res and report if anything unexpected happens. And yeah. The issue might not be a discrepancy in the behavior. I didn't try too hard to debug it so I can't tell for sure what the issue is, only that is happens exclusively on the compat layer. |
@ronag I had a guy that runs my software test it, It didn't seemed to have worked. Let me know if the event wasn't handled properly. |
Oh yea, that is a bug. @jasnell: The if (this[kState].closed) {
const err = new ERR_HTTP2_INVALID_STREAM();
if (typeof cb === 'function')
process.nextTick(cb, err);
this.destroy(err);
return;
} |
Thrilled that solid progress was made. This issue have been a thorn on my side since before v12 came out. I finally added http2 on my software and people had to resort to nginx handling ssl because it would just crash. Now, after this is fixed, the error would be caught by listening to the error event or no error would happen at all? Because I never added a listener to errors on http1 and never had issues either. |
@StephenLynx: FYI #30964 |
HTTP2ServerResponse.write would behave differently than both http1 and streams. This PR makes it more compliant with stream.Writable behaviour. Refs: nodejs#29529
HTTP2ServerResponse.write would behave differently than both http1 and streams. This PR makes it more compliant with stream.Writable behaviour. PR-URL: #30964 Refs: #29529 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
HTTP2ServerResponse.write would behave differently than both http1 and streams. This PR makes it more compliant with stream.Writable behaviour. PR-URL: #30964 Refs: #29529 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
@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. |
@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 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();
} |
HTTP2ServerResponse.write would behave differently than both http1 and streams. This PR makes it more compliant with stream.Writable behaviour. PR-URL: nodejs#30964 Refs: nodejs#29529
HTTP2ServerResponse.write would behave differently than both http1 and streams. This PR makes it more compliant with stream.Writable behaviour. PR-URL: nodejs#30964 Refs: nodejs#29529 Backport-PR-URL: nodejs#31444
HTTP2ServerResponse.write would behave differently than both http1 and streams. This PR makes it more compliant with stream.Writable behaviour. Backport-PR-URL: #31444 PR-URL: #30964 Refs: #29529 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
HTTP2ServerResponse.write would behave differently than both http1 and streams. This PR makes it more compliant with stream.Writable behaviour. Backport-PR-URL: #31444 PR-URL: #30964 Refs: #29529 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Rich Trott <[email protected]>
https://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.
The text was updated successfully, but these errors were encountered: