`UND_ERR_SOCKET` in fetch
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 7.7k
- Forks
- 880
- Avg merge
- 2d 16h
- Merged PRs (30d)
- 68
Description
Sometimes fetch ends up with exception:
{
cause: {
name: "SocketError",
code: "UND_ERR_SOCKET",
socket: {
localAddress: "192.168.1.33",
localPort: 12345,
remoteAddress: "X.Y.Z.W",
remotePort: 443,
remoteFamily: "IPv4",
timeout: undefined,
bytesWritten: 651,
bytesRead: 441,
},
message: "other side closed",
stack: "SocketError: other side closed\n at TLSSocket.onSocketEnd (node:internal/deps/undici/undici:9499:26)\n at TLSSocket.emit (node:events:524:35)\n at endReadableNT (node:internal/streams/readable:1359:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:82:21)"
},
message: "fetch failed",
stack: "TypeError: fetch failed\n at Object.fetch (node:internal/deps/undici/undici:12789:11)\n at async Object.xyzFunc..."
}
Unfortunately, we don't have a reproducible code, because of complexity of application, the initial fetch requests work, but after making some further fetch 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 node fetch, works from postman.
( Windows 11, tested results below with v19.6, however same issue happens in 18.14)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No reproducible code, file, or test is provided. Start by isolating the sporadic fetch request on Windows and comparing it with the same request in Postman; done means identifying a reliable reproduction and documenting or fixing the cause of the UND_ERR_SOCKET failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100