remix: `FetchError: request to http://0.0.0.0:8000/graphql failed, reason: socket hang up`
What version of Remix are you using?
1.7.3
Steps to Reproduce
I have a graphql server. Making a single request to it in loader or action works fine. But if I have multiple requests:
await graphqlSdk().getStuff();
await graphqlSdk().getStuff();
it fails with the following error:
FetchError: request to http://0.0.0.0:8000/graphql failed, reason: socket hang up
at ClientRequest.<anonymous> (/workspace/node_modules/.pnpm/@remix-run+web-fetch@4.3.1/node_modules/@remix-run/web-fetch/src/fetch.js:111:11)
at ClientRequest.emit (node:events:513:28)
at Socket.socketOnEnd (node:_http_client:512:9)
at Socket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at processTicksAndRejections (node:internal/process/task_queues:82:21) {
type: 'system',
errno: 'ECONNRESET',
code: 'ECONNRESET',
erroredSysCall: undefined
}
Expected Behavior
The requests should succeed and my backend should receive 2 requests.
Actual Behavior
The first request succeeds but the second one does not.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 21 (1 by maintainers)
Commits related to this issue
- feat(website): replace using `axios` with `fetch` Using the solution at https://github.com/remix-run/remix/issues/4414#issuecomment-1315139356. However, it would be better if we do not have to write ... — committed to IgnisDa/codefarem by IgnisDa 2 years ago
- IgnisDa/issue1 (#12) * build(rust): optimize binaries for size * style(moon): remove comments from file * build: pin dependencies * chore(react-ui): add react imports to components * ci: ... — committed to IgnisDa/codefarem by IgnisDa 2 years ago
Ran into this after upgrading our remix project to node 20 as well. Can also confirm manually setting the
connectionheader resolved the issue for us. The error triggered when we made multiple requests to the same API server in a single loader.Can confirm
headers: { connection: "keep-alive" }fixes it.@IgnisDa I’m using a library that ends up calling
fetchdown the call stack. There is no options to pass through headers tofetch. The path of least resistance is probably to just wholesale copy some of their code for the time being.Having the same issue here. Will try to put together a minimal example. At the moment it seems like the issue is with web-fetch as simple node:http.request works fine.