-
Notifications
You must be signed in to change notification settings - Fork 518
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
UND_ERR_SOCKET
in fetch
#1923
Comments
That error should also have a message...? |
sorry, I didnt notice I hadnt copied full object. I've updated the message, please refresh page to see it. |
So that looks like the server has just forcefully killed the connection... doesn't seem client related |
can you give me hints what I should refer to? I havent faced any issue across numerous different libs, and havent faced http/s request which ends up without returning response. Server returns some response and headers, and our app works with |
hard to understand the criteria when it happens, almost impossible to find out, spent several hours already. What I spotted, this might theoretically be (?) related to VSCODE debugger, as when i run the code through debugger (but even sometimes works if I quickly step over the method, but sometimes not when I run step by step). well, what I can say is that it perfectly works through |
This happens when the socket is closed before receiving a status code (more or less). I believe it's been a known 'issue' for a while now. reproimport { fetch } from 'undici'
import { createServer } from 'http'
import { once } from 'events'
const server = createServer((req, res) => {
res.socket.end()
}).listen(0)
await once(server, 'listening')
await fetch(`http://localhost:${server.address().port}`) |
if it works with other libs (i.e. |
In the case above, it will also fail with node-fetch (which uses node's http and https modules). If it works with node-fetch, then I'd consider it a bug in undici. However we'd need a small repro to work with. |
This is a working repro anyone can test (I will try to maintain
Output from above is:
PS: I am running |
The fetch implementation in Node v18.1.0 is quite buggy. Could you update to the latest Node.js v18 line and check if the problem still holds? |
Yes, |
Is it possible to catch this acception? I am reading a stream from remote api and this error occurs, but cannot be caught in try/catch.
|
Hey fellow undici users !
Do you have any ideas ? |
Sorry, but you have not really provided us with any information we use to help you... other than that "We detected some UND_ERR_SOCKET errors". |
I have this exact same problem in node 20.
Not sure how to produce an example when it's sporadic. Looks like it is when there is quite a lot of concurrent requests. |
A few things:
If we have a reproduction, we can fix it. Please give us:
We will investigate this. Alternatively, somebody would have to contract one of us to dig into their private codebase and identify the problem. Note that it is extremely likely it is related to some other piece of your infrastructure cutting the connection for whatever reason. |
Sometimes
fetch
ends up with exception:Unfortunately, we don't have a reproducible code, because of complexity of application, the initial
fetch
requests work, but after making some furtherfetch
we sporadically get the error. Do you have any suggestions? Have tried all workaround found in internet, but nothing worked. The exact request which fails with nodefetch
, works frompostman
.( Windows 11, tested results below with v19.6, however same issue happens in 18.14)
The text was updated successfully, but these errors were encountered: