Skip to content
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

node/h2 (dns-resolver): Uncaught error #32

Closed
2 tasks
amithm7 opened this issue Dec 20, 2021 · 6 comments
Closed
2 tasks

node/h2 (dns-resolver): Uncaught error #32

amithm7 opened this issue Dec 20, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@amithm7
Copy link
Contributor

amithm7 commented Dec 20, 2021

DNSResolver.prototype.doh2 = async function (request) {

  • Probably check if http2Session (c) is not destroyed before calling c.close() ?
  • Error handlers on c and req aren't closing the http2Session either, but just rejecting promise. destroy the socket on error?

Type 1:

2021-12-20T10:35 app [info] node:internal/errors:464
2021-12-20T10:35 app [info]     ErrorCaptureStackTrace(err);
2021-12-20T10:35 app [info]     ^
2021-12-20T10:35 app [info] Error [ERR_STREAM_PREMATURE_CLOSE]: Premature close
2021-12-20T10:35 app [info]     at new NodeError (node:internal/errors:371:5)
2021-12-20T10:35 app [info]     at Http2ServerRequest.onclose (node:internal/streams/end-of-stream:122:30)
2021-12-20T10:35 app [info]     at Http2ServerRequest.emit (node:events:390:28)
2021-12-20T10:35 app [info]     at ServerHttp2Stream.onStreamAbortedRequest (node:internal/http2/compat:191:13)
2021-12-20T10:35 app [info]     at ServerHttp2Stream.emit (node:events:402:35)
2021-12-20T10:35 app [info]     at closeStream (node:internal/http2/core:1896:14)
2021-12-20T10:35 app [info]     at ServerHttp2Stream.close (node:internal/http2/core:2268:5)
2021-12-20T10:35 app [info]     at node:internal/http2/core:3218:46
2021-12-20T10:35 app [info]     at Map.forEach (<anonymous>)
2021-12-20T10:35 app [info]     at TLSSocket.socketOnClose (node:internal/http2/core:3218:19) {
2021-12-20T10:35 app [info]   code: 'ERR_STREAM_PREMATURE_CLOSE'
2021-12-20T10:35 app [info] }
2021-12-20T10:35 app [info] Node.js v17.2.0
2021-12-20T10:35 app [info] Main child exited normally with code: 1
2021-12-20T10:35 app [info] Starting clean up.
2021-12-20T10:35 proxy [error] Error 2: Internal problem
2021-12-20T10:35 proxy [error] Error 2: Internal problem
2021-12-20T10:35 proxy [error] Error 2: Internal problem
2021-12-20T10:35 proxy [error] Error 2: Internal problem

Type 2:

2021-12-19T05:06:16.851 node:events:368
2021-12-19T05:06:16.851       throw er; // Unhandled 'error' event
2021-12-19T05:06:16.851       ^
2021-12-19T05:06:16.851 Error [ERR_HTTP2_STREAM_CANCEL]: The pending stream has been canceled (caused by: connect ECONNREFUSED 2620:fe::10:443)
2021-12-19T05:06:16.851     at new NodeError (node:internal/errors:371:5)
2021-12-19T05:06:16.851     at closeSession (node:internal/http2/core:1138:20)
2021-12-19T05:06:16.851     at ClientHttp2Session.destroy (node:internal/http2/core:1517:5)
2021-12-19T05:06:16.851     at TLSSocket.socketOnError (node:internal/http2/core:2968:13)
2021-12-19T05:06:16.851     at TLSSocket.emit (node:events:390:28)
2021-12-19T05:06:16.851     at emitErrorNT (node:internal/streams/destroy:164:8)
2021-12-19T05:06:16.851     at emitErrorCloseNT (node:internal/streams/destroy:129:3)
2021-12-19T05:06:16.851     at processTicksAndRejections (node:internal/process/task_queues:83:21)
2021-12-19T05:06:16.851 Emitted 'error' event on ClientHttp2Stream instance at:
2021-12-19T05:06:16.851     at emitErrorNT (node:internal/streams/destroy:164:8)
2021-12-19T05:06:16.851     at emitErrorCloseNT (node:internal/streams/destroy:129:3)
2021-12-19T05:06:16.851     at processTicksAndRejections (node:internal/process/task_queues:83:21) {
2021-12-19T05:06:16.851   cause: Error: connect ECONNREFUSED 2620:fe::10:443
2021-12-19T05:06:16.851       at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1157:16) {
2021-12-19T05:06:16.851     errno: -111,
2021-12-19T05:06:16.851     code: 'ECONNREFUSED',
2021-12-19T05:06:16.851     syscall: 'connect',
2021-12-19T05:06:16.851     address: '2620:fe::10',
2021-12-19T05:06:16.852     port: 443
2021-12-19T05:06:16.852   },
2021-12-19T05:06:16.852   code: 'ERR_HTTP2_STREAM_CANCEL'
2021-12-19T05:06:16.852
@ignoramous
Copy link
Contributor

ignoramous commented Dec 21, 2021

Hand rolling h2 client impl is bound to be painful. There must be a h2 connection pooler for nodejs that we could use instead?

@amithm7 amithm7 added the bug Something isn't working label Dec 24, 2021
@amithm7
Copy link
Contributor Author

amithm7 commented Jan 19, 2022

33e9107#diff-44a45c9712fe990be7f4a663b633093cfea79701030c03f4f1f1dabc6a3987fcL194-R231

may have fixed this...

@ignoramous
Copy link
Contributor

That it did.

@ignoramous
Copy link
Contributor

Still see ERR_STREAM_PREMATURE_CLOSE with super regularity in prod #115 (never could reproduce it on my laptop).

Not sure if it is the fetch polyfill that's buggy (ex0), or there some special error handling that's needed for http2 server (ref, ex1), or the h2 session objs need to be moped up gracefully (code).

@amithm7
Copy link
Contributor Author

amithm7 commented Feb 6, 2023

Not sure if it is the fetch polyfill that's buggy

node-fetch isn't being used !? (it's replacement undici was removed too in c162cd4)

@ignoramous
Copy link
Contributor

Yeah, the built-in polyfill... ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants