Skip to content

Problems with HTTP/2 Invalid Stream #40

@FuyukiWolfer

Description

@FuyukiWolfer

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions