microsoft / microsoft/monaco-editor
[Bug] Getting `Canceled: Canceled` error when disposing the editor
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 46.8k
- Forks
- 4.1k
- Avg merge
- 17h 58m
- Merged PRs (30d)
- 1
Description
Reproducible in vscode.dev or in VS Code Desktop?
- Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
- Not reproducible in the monaco editor playground
Monaco Editor Playground Link
No response
Monaco Editor Playground Code
Reproduction Steps
No response
Actual (Problematic) Behavior
We are experiencing an issue when disposing monaco editors when running a QUnit test.
I'm using Ember.js and this is in my component:
registerDestructor(this, async () => {
let editor = this.monacoState?.editor;
if (editor) {
editor.dispose();
}
});
When component gets destroyed, registerDestructor will be called and this is where we dispose of the editor. This worked fine in 0.33.0 but now that I upgraded to 0.52.2., I am receiving an error in my QUnit component test where I am rendering a monaco editor.
There must be a timing issue because if I add a small delay at the end of my test, or at the end of my registerDestructor, then the error will not happen.
stack: >
Canceled: Canceled
at Delayer.cancel (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:237183:23)
at Delayer.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:237192:10)
at dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245841:13)
at DisposableStore.clear (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245923:7)
at DisposableStore.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245907:10)
at WordHighlighter.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:388991:19)
at WordHighlighterContribution.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:389044:29)
at dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245841:13)
at DisposableMap.clearAndDisposeAll (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:246082:7)
at DisposableMap.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:246072:10)
at dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245841:13)
at DisposableStore.clear (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245923:7)
at DisposableStore.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245907:10)
at CodeEditorContributions.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245984:17)
at dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245841:13)
at DisposableStore.clear (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245923:7)
at DisposableStore.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245907:10)
at StandaloneEditor.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:245984:17)
at StandaloneEditor.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:2[821](https://github.com/cardstack/boxel/actions/runs/14059476194/job/39366512451?pr=2338#step:12:822)84:11)
at StandaloneEditor.dispose (http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:391795:11)
at http://localhost:7357/assets/chunk.d02b4ddf827a71f02c1e.js:463290:17
at invoke (http://localhost:7357/assets/vendor.js:39370:16)
at Queue.flush (http://localhost:7357/assets/vendor.js:39286:13)
at DeferredActionQueues.flush (http://localhost:7357/assets/vendor.js:39440:21)
at Backburner._end (http://localhost:7357/assets/vendor.js:39868:34)
at Backburner.end (http://localhost:7357/assets/vendor.js:39671:12)
at Backburner._run (http://localhost:7357/assets/vendor.js:39912:16)
at Backburner._join (http://localhost:7357/assets/vendor.js:39889:21)
at Backburner.join (http://localhost:7357/assets/vendor.js:39711:19)
at join (http://localhost:7357/assets/vendor.js:25723:24)
at ApplicationInstance.destroy (http://localhost:7357/assets/vendor.js:9891:27)
at ApplicationInstance.superWrapper [as destroy] (http://localhost:7357/assets/vendor.js:10529:22)
at ensureDestroyCalled (http://localhost:7357/assets/vendor.js:17744:16)
at http://localhost:7357/assets/vendor.js:26713:45
at iterate (http://localhost:7357/assets/vendor.js:26635:7)
at destroy (http://localhost:7357/assets/vendor.js:26713:5)
at iterate (http://localhost:7357/assets/vendor.js:26635:7)
at destroy (http://localhost:7357/assets/vendor.js:26712:5)
at http://localhost:7357/assets/chunk.d02b4ddf[827](https://github.com/cardstack/boxel/actions/runs/14059476194/job/39366512451?pr=2338#step:12:828)a71f02c1e.js:508416:64
message: >
global failure: Canceled: Canceled
```
### Expected Behavior
_No response_
### Additional Context
Monaco version: 0.52.2.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the QUnit component test with Monaco 0.52.2 and inspect the disposal path shown in the stack, especially Delayer and WordHighlighter disposal. The issue is resolved when disposing the editor during component teardown no longer produces the global Canceled: Canceled failure without requiring an added delay.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100