sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.26k stars 935 forks source link

Error: Session closed without receiving a SETTINGS frame (from http2-wrapper) #2210

Open kevinlul opened 1 year ago

kevinlul commented 1 year ago

Describe the bug

Actual behavior

Process crashed. Final log:

/app/node_modules/http2-wrapper/source/agent.js:396
                                                        const error = new Error('Session closed without receiving a SETTINGS frame');
                                                                      ^
Error: Session closed without receiving a SETTINGS frame
    at ClientHttp2Session.<anonymous> (/app/node_modules/http2-wrapper/source/agent.js:396:22)
    at Object.onceWrapper (node:events:627:28)
    at ClientHttp2Session.emit (node:events:513:28)
    at emitClose (node:internal/http2/core:1086:8)
    at TLSSocket.<anonymous> (node:internal/http2/core:1113:7)
    at TLSSocket.emit (node:events:525:35)
    at node:net:320:12
    at TCP.done (node:_tls_wrap:588:7)
Emitted 'error' event on ClientRequest instance at:
    at ClientRequest.flushHeaders (/app/node_modules/http2-wrapper/source/client-request.js:363:10) {
  code: 'HTTP2WRAPPER_NOSETTINGS'
}
Node.js v18.13.0

Expected behavior

Process does not crash on bad behaviour from a server when the got call is already wrapped in a try-catch.

Code to reproduce

Due to the total lack of context from the stack trace, none can be provided. It is unclear exactly what request caused it. However, all calling code is essentially

try {
    await got(url);
} catch (e) {
    console.error(e);
}

I am seeing that got v11 depends on http2-wrapper 1.0.0-beta.5.2, whereas there are significantly newer versions of this dependency for both v1 and v2 that are not in beta, so that may resolve the issue.

Checklist

aPoCoMiLogin commented 1 year ago

exactly the same issue, process is crashing due to unhandledRejection

douglascayers commented 11 months ago

For anyone else coming here: FYI, got 11.x is no longer maintained and won't receive the dependency update: https://github.com/sindresorhus/got/issues/2277#issuecomment-1612801140

I'm going to try @kevinlul approach of updating the dependency manually: https://github.com/DawnbrandBots/bastion-bot/issues/268