Skip to content
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

If you're fetching data and an error is thrown, the data continues fetching, and fetching... #736

Open
scf4 opened this issue Feb 24, 2020 · 1 comment

Comments

@scf4
Copy link

scf4 commented Feb 24, 2020

We have a max size of 20mb set since the servers we fetch from can sometimes give us an endless amount of data (I mean 12 hours of useless 300GB data endless! 😄).

Once the size limit is breached, node-fetch successfully throws an error, the promise is rejected — but the HTTP request isn't stopped, so everything appears fine.

That is until you suddenly see huge spikes in inbound traffic and CPU, and eventually realize a node process has been running for 12 hours instead of 12 seconds!

Is this part of the spec, or a bug? It feels like unexpected behavior to me.

Thanks!

@bitinn
Copy link
Collaborator

bitinn commented Mar 13, 2020

Consider looking into these:

  • Set a timeout or use AbortSignal to the same effect.
  • In v3 release, we are more strict in piping network related errors, so hopefully this issue won't be repeated.
  • Normally the underlying connection should timeout according to your OS socket setup, I haven't seen a situation where node-fetch keeps the connection alive (we default to keep-alive: close), so you might want to look into your agent config and your OS config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants