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

feat: support AbortController signal #125

Merged
merged 6 commits into from
Jul 13, 2021
Merged

feat: support AbortController signal #125

merged 6 commits into from
Jul 13, 2021

Conversation

aaarichter
Copy link

@aaarichter aaarichter commented Jul 12, 2021

  • feat: support AbortController signal
  • chore(deps): update dependencies
  • ci: add node 16 to test matrix & remove travis config
const { fetch } = require('gofer');
const ac = new AbortController(); // Node 15+

ac.signal.addEventListener('abort', () => console.log('Aborted!'), { once: true });

await Promise.race([
  fetch('https://example.com', { signal: ac.signal }).text().catch(err => /*  err this will say it was aborted */),
  async () => { return '<html>'; }
]).finally(() => ac.abort());

Copy link

@JimLiu JimLiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@aaarichter aaarichter merged commit 4d6e6a1 into main Jul 13, 2021
@aaarichter aaarichter deleted the abort branch July 13, 2021 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants