Skip to content

fix: [#2339] Prevent unhandled rejection in Animation.cancel() - #2340

Open
CNSeniorious000 wants to merge 3 commits into
capricorn86:masterfrom
CNSeniorious000:fix/2339-animation-finished-cancel
Open

fix: [#2339] Prevent unhandled rejection in Animation.cancel()#2340
CNSeniorious000 wants to merge 3 commits into
capricorn86:masterfrom
CNSeniorious000:fix/2339-animation-finished-cancel

Conversation

@CNSeniorious000

@CNSeniorious000 CNSeniorious000 commented Sep 1, 2026

Copy link
Copy Markdown

Description

Animation.cancel() can fail tests with an unhandled AbortError even when finished is never read. Following the cancellation algorithm, mark the promise handled, replace it on cancellation, and reuse the replacement on idle-to-play while preserving the old promise's rejection.

Resolves #2339

Before submitting the PR, please make sure you do the following:

  • Read the contributing guidelines.
  • It's really useful if your PR references an issue where it is discussed ahead of time.
  • Please check Allow edits by maintainers to make review process faster. Note that this option is not available for repositories that are owned by Github organizations.

Tests

  • Make sure to add tests for your changes. Run your test in a real browser to make sure that the test tests what a real browser would do (e.g. by running the code in the browser console).
  • Run the tests with npm test locally to make sure that all tests pass before submitting the PR.

CI passed on Node 20, 22, and 24.

Local validation: 205 Animation/Element tests, TypeScript compilation, ESLint, and Prettier passed. Earlier Chromium 148 checks confirmed promise identity and cancellation behavior. The earlier full local run had 9 macOS canvas snapshot mismatches; the current full compile attempt hit a chromium.googlesource.com download timeout.

Title

  • The title of the pull request should be in the format of "type: [#issue] description". The type can be feat, fix, chore or BREAKING CHANGE. The issue is optional and can be omitted if the pull request does not relate to an issue.
  • The title should be concise and descriptive. The title will be used when generating release notes. Make sure that the title is easily understood by users of the library.

AI tools

  • Please disclose in the PR description that you used AI tools to generate code. This is important for transparency and to ensure that the generated code meets the quality standards of the project.

AI-assisted with Codex and Claude Code.

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

Successfully merging this pull request may close these issues.

Animation.cancel() causes an unhandled rejection when finished is never read

1 participant