Promise.cancel()
See original GitHub issueWould it be consistent in 3.0 to add static Promise.cancel()
to return a new promise in cancelled state? (like Promise.resolve()
and Promise.reject()
)
Promise.cancel = function() {
var p = Promise(function(){});
p.cancel();
return p;
}
Issue Analytics
- State:
- Created 8 years ago
- Comments:35 (29 by maintainers)
Top Results From Across the Web
Cancel a vanilla ECMAScript 6 Promise chain - Stack Overflow
Promise can be cancelled with the help of AbortController . Is there a method for clearing then: ...
Read more >How to cancel a promise in javascript ? - DEV Community
Promise cannot be cancelled, it is the process that returns promise must be cancellable. For example, XmlHttpRequest is cancellable as it has an ......
Read more >You can already cancel ES6 Promises - gists · GitHub
The gist: by having a Promise adopt the state of a forever pending one, you can suspend its then handlers chain. Promise.pending =...
Read more >Promise Cancellation Is Dead — Long Live ... - Ben Lesh
I want to be clear: You can't cancel a Promise. (I know, I know, mixed messages)… If something gives you a promise, your...
Read more >How to Cancel That Embarrassing Email
Try canceling the promise before it gets a chance to start. You should see no countdown numbers at all: startCountingForHideAndSeek().cancel() ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Even more surprising is that now
produces
so the chain is broken.
But the same code with
Promise.resolve({body: "A"})
produces:
So the chain is not broken
O_o? (bye-bye mocked requests in unit/integration tests?) Worth it to be registered as a new issue?
@benjamingr cancellation isn’t rejection with cancellation in 3.0