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

Directly accessing isCancelled when declaring variables, it returns false #1718

Open
JackWang032 opened this issue Nov 18, 2024 · 0 comments

Comments

@JackWang032
Copy link

(This issue tracker is only for bug reports or feature requests, if this is neither, please choose appropriate channel from http://bluebirdjs.com/docs/support.html)

Please answer the questions the best you can:

  1. What version of bluebird is the issue happening on?
    3.7.2
  2. What platform and version? (For example Node.js 0.12 or Google Chrome 32)
    Chrome 130.0.6723.70
  3. Did this issue happen with earlier version of bluebird?
    3.x
    (Write description of your issue here, stack traces from errors and code that reproduces the issue are helpful)

it works right if cancel the root promise

let p = CancellablePromise.delay(1000).finally(() => {
  console.log(p.isCancelled())
});
p.cancel();
// print true

if you declare another promise instance, you must access the isCancelled state asynchronously.

let p = CancellablePromise.delay(1000);
let p1 = p.then().finally(() => {
    console.log('a:', p1.isCancelled());
    setTimeout(() => {
        console.log('b:', p1.isCancelled());
     }, 0)
})
p.cancel();

// print a: false,  b: true
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

1 participant