question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AbortSignal integration

See original GitHub issue

Hello,

This library looks wonderful. One thing that makes it a bit hard for us & probably other folks to adopt & use is that it escew’s the web (and increasingly the rest of js too) standard AbortSignal cancellation protocols.

There are some various api differences between the standard JS abort protocols & the CancellationToken presently in use in cockatiel. The main difference is that CancellationToken is both the means to observe change, and the system for doing the change. This is reminisce of the old jQuery Deferrable, which was a precursor to promises, where the Deferrable was both the promise & the resolver. In JS today, usually the thing that does the actuating/changing is separate from the system for observing. That is reflected in AbortSignal and it’s pair AbortController, where AbortSignal is the output (somewhat alike a sychronously readable Promise), and AbortController can be used to actuate the signal (quite strongly resembling the obsolete JS Deferred, which contrary to jquery, divided the promise & the resolver ala AbortSignal/AbortController). First used in Fetch, today, AbortSignal is being widely integrated into the JS ecosystem.

Please pardon my long-windedness above. I find it interesting to provide some historical roots for the topic, as they show how things have moved over time, but I am mainly writing this ticket to talk about today & the future & how cockatiel can be the best JS citizen it can be. CancellationToken has a pretty nice, convenient, & very powerful set of APIs atop it, and I generally commend the Microsoft teams that have shaped it over the years. However, I feel like it’s in cockatiel’s best interest prefer to integrate with the JS language ecosystem, if possible, and feel like we should try to switch to AbortSignal/AbortController as the primary means to handle/deal-with cancellation concerns.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
connor4312commented, Nov 14, 2021

I published 3.0.0-beta.0. It’s a prerelease tag so will need to be explicitly installed.

1reaction
connor4312commented, Nov 13, 2021

I’ve now done this. However, as AbortController/AbortToken is only available in Node.js starting in v16, I will wait to publish this until the end of April when Node 12 enters EOL and Node 18 is released.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AbortSignal: abort event - Web APIs - MDN Web Docs - Mozilla
In the following snippets, we create a new AbortController object, and get its AbortSignal (available using the signal property).
Read more >
Using AbortController as an Alternative for Removing Event ...
But the big news is that addEventListener now accepts an Abort Signal as of Chrome 88. What's cool about that? It can be...
Read more >
How to Cancel Promise with AbortController - LeanyLabs
API's that support cancellation can take the AbortSignal object, listen to an abort event and stop the operation. To make error handling much...
Read more >
AbortController in modular AWS SDK for JavaScript
The API that wants to support aborting can accept an AbortSignal object, and is encouraged to respond to abort() by rejecting any unsettled ......
Read more >
How to integrate AbortController with Axios and React?
getTest(signal?: AbortSignal): Promise<AxiosResponse<Test[]>> { return axios.get(`${URI}/test`, { signal }); },. When using Axios.CancelToken.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found