Skip to content

Unhandled CancellationError in WordHighlighter when disposed during pending delayed operation. #285890

@junhaoliao

Description

@junhaoliao

Does this issue occur when all extensions are disabled?: Yes

Summary

Unhandled CancellationError in WordHighlighter when disposed during pending delayed operation.

Reported in monaco-editor: microsoft/monaco-editor#4702

Steps to Reproduce

  1. Clone https://github.com/y-scope/yscope-log-viewer.git
  2. Run npm ci then npm run dev
  3. Open the browser console

Actual Behavior

The following error appears in the console:

Uncaught (in promise) Canceled: Canceled
    CancellationError errors.js:91
    cancel async.js:251
    dispose async.js:260
    dispose lifecycle.js:24
    clear lifecycle.js:114
    dispose lifecycle.js:98
    dispose wordHighlighter.js:652
    dispose wordHighlighter.js:709
    dispose lifecycle.js:24

Expected Behavior

No unhandled promise rejection. The CancellationError should be caught and suppressed since it's expected during disposal.

Root Cause

In src/vs/editor/contrib/wordHighlighter/browser/wordHighlighter.ts, there are three calls to runDelayer.trigger() that don't handle the rejected promise when the delayer is cancelled during disposal.

Proposed Fix

Add .catch(onUnexpectedError) to all three runDelayer.trigger() calls. The onUnexpectedError function automatically filters out CancellationError, so only genuine unexpected errors are reported.

This follows the same pattern used in:

  • parameterHintsModel.ts
  • findWidget.ts
  • stickyScrollModelProvider.ts

Metadata

Metadata

Assignees

Labels

insiders-releasedPatch has been released in VS Code Insiders

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions