question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems with HTTP/2 Invalid Stream

See original GitHub issue

Version: 11.11.0 OS: Windows 10 Home (64-bit)

I am using Fastify HTTP Proxy to get the CDN (S3 + Cloudfront) files and avoid CORS or CSP problems, but sometimes the request fail and generate a error ERR_HTTP2_INVALID_STREAM that crash de Node.js Application, so i started observe that and always the request that crash the app was from the proxy.

This error decreases a lot, but even so it still occurs, and in addition another error began to appear the HTTP2_ENHANCE_YOUR_CALM that after the error all requests from the proxy result in a Internal Server Error (Code: 500) and the only way to resolve that is restarting the app.

To try resolve this error, i used GZIP compression from the Cloudfront Server to not compress the files from the CDN by the Fastify Compress, this helped a lot, a way to bypass the Invalid Stream Error is using a UncaughtException what is not secure to use, handling the error the requests throw the error but the app works, the files load and not crash, but i really not want continue doing that.

The normal routes from the Fastify works fine, the only problem is that error that can occur any time, not guaranteeing the stability of the application. So how can i fix that?

Note: I am starting work with JS and Node.js recently, so i may have done something wrong, you can check the code that i am using on my profile, the name is ACS. Thanks!

Error [ERR_HTTP2_INVALID_STREAM]: The stream has been destroyed
    at Http2ServerResponse.write (internal/http2/compat.js:606:19)
    at IncomingMessage.ondata (_stream_readable.js:693:20)
    at IncomingMessage.emit (events.js:197:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at IncomingMessage.Readable.push (_stream_readable.js:224:10)
    at HTTPParser.parserOnBody (_http_common.js:126:22)
    at TLSSocket.socketOnData (_http_client.js:447:20)
    at TLSSocket.emit (events.js:197:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at TLSSocket.Readable.push (_stream_readable.js:224:10)
    at TLSWrap.onStreamRead [as onread] (internal/stream_base_commons.js:145:17)
Error [ERR_HTTP2_INVALID_STREAM]: The stream has been destroyed
    at Http2ServerResponse.write (internal/http2/compat.js:606:19)
    at Duplexify.ondata (C:\Users\Wolfer\Documents\App\node_modules\readable-stream\lib\_stream_readable.js:619:20)
    at Duplexify.emit (events.js:197:13)
    at addChunk (C:\Users\Wolfer\Documents\App\node_modules\readable-stream\lib\_stream_readable.js:291:12)
    at readableAddChunk (C:\Users\Wolfer\Documents\App\node_modules\readable-stream\lib\_stream_readable.js:278:11)
    at Duplexify.Readable.push (C:\Users\Wolfer\Documents\App\node_modules\readable-stream\lib\_stream_readable.js:245:10)
    at Duplexify._forward (C:\Users\Wolfer\Documents\App\node_modules\duplexify\index.js:170:26)
    at Gzip.onreadable (C:\Users\Wolfer\Documents\App\node_modules\duplexify\index.js:134:10)
    at Gzip.emit (events.js:197:13)
    at emitReadable_ (_stream_readable.js:539:12)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
FuyukiWolfercommented, Mar 20, 2019

Hi @srmarjani, you can force the issue executing sometimes this autocannon -a 40 https://localhost:3000/cdn/app/pcomunic/img/index/cover.jpg for example, when you see that the request finish with status 500 is because occur HTTP2_ENHANCE_YOUR_CALM error, and the ERR_HTTP2_INVALID_STREAM how i said is randomly, i will try find a way to get this error, if i find i will comment here.

0reactions
mcollinacommented, Nov 15, 2019

In theory yes. Closing for now, it might be we should reopen in case it’s still a problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error: RPC failed; curl 92 HTTP/2 stream 0 was not closed ...
It sounds like either the remote server you're using or some middlebox (e.g., a proxy) is not speaking the HTTP/2 protocol correctly. You...
Read more >
[#QTBUG-94470] Incorrect parsing of HTTP2 frame headers.
Incorrect parsing of HTTP2 frame headers. This happens when using Netty as the server, in the Java gRPC implementation server, in QtProtobuf ...
Read more >
HTTP/2 Frequently Asked Questions
HTTP/1.x has a problem called “head-of-line blocking,” where effectively only one request can be outstanding on a connection at a time.
Read more >
stream error in the http/2 framing layer - WordPress.org
While debugging further, we are getting below issue details from CURL command. http2 error: Invalid HTTP header field was received: frame type: 1,...
Read more >
mod_http2 - Apache HTTP Server Version 2.4
The problem is that you will have multiple requests for multiple hosts on the same TLS connection. And that makes renegotiation impossible, in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found