Open jackschu opened 8 months ago
Yeah, that's a good catch and indeed a bug. Both belong to a single stream that is most likely tight to a single request/response lifecycle for fetch
and undici
itself.
There's no reason to reuse the same, it was most likely left over we forgot to check.
Would you like to send a PR? It might be hard, but let's see if we can add some tests.
I can take care of this issue if it's appropriate
Sure I can look at adding this patch + some test coverage, It'll likely be outside of my working hours so may be a week or so
I took a swing at this but am running into some trouble around ClientDestroyedError
Currently something like this would result in the promise hanging, I don't think that's correct, and should instead result in a reject
client.on('connect', () => {
client.close()
})
await client.request({
path: '/',
method: 'GET',
})
but just calling errorRequest
on error in client.js
's stream error handler results in a ClientDestroyedError
seemingly if the client is closed without the body having been consumed eg the following will throw
await client.request({
path: '/',
method: 'GET',
})
await client.close()
Any advice around how to handle this?
Can you provide the full Minimum Reproducible Example?
Feel free to also open a PR and we can iterate from it
I opened a pr thank you very much for your support and explanations I hope I did it right if you have any suggestions please do not hesitate @metcoder95 @jackschu
Bug Description
If node closes a http2stream with
NGHTTP2_INTERNAL_ERROR
, theawait dispatch
in httpNetworkFetch() in fetch/index.js will never resolveReproducible By
The tricky part about reproducing is understandably getting node to throw this error. Reproductions seem related to sending many large http2 post requests via the fetch api to the same endpoint while the event loop is busy.
Expected Behavior
The promise is rejected rather than left unfulfilled.
Logs & Screenshots
With NODE_DEBUG=http2 I can see code 2 (NGHTTP2_INTERNAL_ERROR) being thrown
If i add a call to
errorRequest
here in writeH2() i can see the following error and my expected behavior of rejecting the promisePrimary question
Why is errorRequest used only in the frameError handler and not the error handler? How else should this promise end up rejected?
Environment
Undici: 5.28.1 OS: nixos 5.23.11 Node: v18.18.2