Coder Social home page Coder Social logo

Comments (3)

Moumouls avatar Moumouls commented on June 10, 2024 2

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.

zalox avatar zalox commented on June 10, 2024

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.

isaacs avatar isaacs commented on June 10, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.