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

Coroutines doesn't support immediate cancellation #15

Closed
glureau opened this issue Feb 25, 2022 · 1 comment
Closed

Coroutines doesn't support immediate cancellation #15

glureau opened this issue Feb 25, 2022 · 1 comment
Assignees

Comments

@glureau
Copy link
Collaborator

glureau commented Feb 25, 2022

    const abortController = new AbortController();
    const { signal: abortSignal } = abortController;
    var promise = longCompute(abortSignal); // Get a Promise from Kotlin
    abortController.abort(); // Won't work
    
    // Workaround: await just a bit so the promise Kotlin is actually created and listen the `onabort`
    await new Promise((resolve) => {
      setTimeout(resolve, 0);
    });
    abortController.abort(); // Works

The first call to abort() should work.

@glureau glureau self-assigned this Mar 6, 2022
@glureau
Copy link
Collaborator Author

glureau commented Mar 6, 2022

Fixed by c7a4ddc (impacting v0.4.1 and previous)

@glureau glureau closed this as completed Mar 6, 2022
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