Comments (3)
My team encountered the same issue. In our test suite for impacted test we provided a new agent without keep alive.
Btw, think it's not really an issue of node-fetch, but a new behavior of Node 19 and 20. Since Node 19 the global default agent use keep alive.
The workaround is providing a custom agent for impacted test calls.
import { Agent } from 'http'
import fetch from 'node-fetch'
fetch(myUrl, { agent: new Agent() })
Technically this kind of issue should only occur in test purpose. Another solution is to change the port between each test.
from node-fetch.
I also encountered this bug now when attempting to do consecutive calls to an API. One workaround I found was to include a await new Promise(resolve => resolve(setTimeout));
before the await fetch. So there is probably a synchronization bug somewhere.
The same code base works as expected with node 18, so I switched to that for now.
from node-fetch.
Technically this kind of issue should only occur in test purpose. Another solution is to change the port between each test.
If you make repeated requests to a server in production, and the connection closes between requests, it could happen in production as well. Servers do restart sometimes in real life.
from node-fetch.
Related Issues (20)
- SSL error when setting host: header correctly HOT 1
- Node-fetch allows setting forbidden headers HOT 3
- Could not catch Premature close error HOT 1
- Broken clone() method in newer version of 3.3.* (at least)
- Critical dependency:
- failing without clear reason HOT 3
- FormData with invalid Content-Length HOT 2
- Pure ems bundle prevents node-fetch usage in libraries/frameworks HOT 2
- Can't import HOT 1
- v2.7.0: punycode is deprecated in 'whatwg-url' and 'tr46' HOT 3
- Faulty NPM upload 2.7.0 HOT 3
- The 'body' stream never ends for empty HTTP response bodies on Node 16 HOT 1
- Unhandled 'error' event when using AbortSignal to cancel requests HOT 2
- Andoka now
- bug issue
- Error [ERR_REQUIRE_ESM]: require() of ES Module
- Error [ERR_REQUIRE_ESM]: require() of ES Module HOT 1
- Not able to make network call with empty body
- Question:
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-fetch.