-
Notifications
You must be signed in to change notification settings - Fork 38.2k
Description
Does this issue occur when all extensions are disabled?: Yes
- VS Code Version: N/A (
[email protected]) - OS Version: All
Summary
Unhandled CancellationError in WordHighlighter when disposed during pending delayed operation.
Reported in monaco-editor: microsoft/monaco-editor#4702
Steps to Reproduce
- Clone https://github.com/y-scope/yscope-log-viewer.git
- Run
npm cithennpm run dev - 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.tsfindWidget.tsstickyScrollModelProvider.ts