Skip to content

Fix uncaught promise rejection on loading cancellation#669

Open
paulsmirnov wants to merge 3 commits into
mainfrom
616-uncaught-in-promise-error-operation-cancelled
Open

Fix uncaught promise rejection on loading cancellation#669
paulsmirnov wants to merge 3 commits into
mainfrom
616-uncaught-in-promise-error-operation-cancelled

Conversation

@paulsmirnov

Copy link
Copy Markdown
Member

Description

Fixes #616.

When a load operation was cancelled (e.g. by calling load() again before the previous one finished), the internal promise chain rejected with an unhandled error, causing an "Uncaught (in promise)" console error.

  • Introduce CancellationError class, consistent with the existing ParsingError and OutOfMemoryError
  • Use CancellationError across all abort paths in FileLoader, XHRLoader, and Parser
  • Handle it in Miew.load() so the promise resolves normally on cancellation rather than rejecting

Also fix ParsingError and OutOfMemoryError to properly extend Error (prototype chain and name property).

Type of changes

  • Bug fix (non-breaking change that fixes an issue)

Checklist

  • I have read CONTRIBUTING and CODE_OF_CONDUCT guides.
  • I have followed the code style of this project.
  • I have run yarn run ci: lint and tests pass locally with my changes.
  • I have added tests that prove my fix/feature works OR The changes do not require updated tests.
  • I have added the necessary documentation OR The changes do not require updated docs.

paulsmirnov and others added 3 commits June 23, 2026 19:08
Introduce CancellationError class (consistent with the existing
ParsingError and OutOfMemoryError) and use it across all abort
paths.

Co-authored-by: GitHub Copilot <copilot@github.com>
@paulsmirnov paulsmirnov linked an issue Jun 23, 2026 that may be closed by this pull request
@paulsmirnov paulsmirnov self-assigned this Jun 23, 2026
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 25.587% (+0.01%) from 25.577% — 616-uncaught-in-promise-error-operation-cancelled into main

@paulsmirnov paulsmirnov marked this pull request as ready for review June 23, 2026 23:25
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.

Uncaught (in promise) Error: Operation cancelled

2 participants