simonplend / fetch-with-timeout

Cancels HTTP requests with the Abort API. Bring your own Fetch API implementation.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Should I make this a proper package and publish it to npm?

simonplend opened this issue · comments

The AbortSignal.timeout method will hopefully be getting backported to the Node.js 16.x release line in the near future. This allows you to cleanly implement a timeout for an HTTP request with fetch e.g.

const response = await fetch(url, { signal: AbortSignal.timeout(10_000) });

That would potentially make this library redundant. However, it could still be useful for anyone using >= v16.0.0 and < than the v16.x.x release when AbortSignal.timeout is backported. This would be true for people using serverless runtimes such as Google Cloud Functions and AWS Lambda where you can only control the Node.js major version.

Making this library a "proper" package would involve:

  • Adding tests (!)
  • Adding types
  • Improving the documentation
  • Publishing it to npm

If you would find this library helpful, please let me know by dropping a 👍🏻 reaction on this issue!