monaco-editor
monaco-editor copied to clipboard
[Bug] Editor dispose erroring in async.ts
Reproducible in vscode.dev or in VS Code Desktop?
- [X] 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 Code
// The Monaco Editor can be easily created, given an
// empty container and an options literal.
// Two members of the literal are "value" and "language".
// The editor takes the full size of its container.
const mon = monaco.editor.create(document.getElementById('container'), {
autoClosingBrackets: "never",
autoClosingQuotes: "never",
automaticLayout: true, // severe performance impact, but avoiding CSS for now
language: 'csharp',
lineNumbers: "off",
minimap: {
enabled: false,
},
renderValidationDecorations: "off",
scrollbar: {
alwaysConsumeMouseWheel: false,
},
suggest: {
showStatusBar: true,
showWords: false, // There is a weird interaction between editors without this being set to false.
snippetsPreventQuickSuggestions: false,
},
theme: "vs",
value: "22",
});
mon.dispose();
Reproduction Steps
Paste the code on the playground Open a console and put a breakpoint in async.ts line 274 in the cancel() method:
cancel(): void {
this.cancelTimeout();
if (this.completionPromise) {
if (this.doReject) {
this.doReject(new CancellationError()); // HERE
}
this.completionPromise = null;
}
}
Press the Run button
It should hit the breakpoint
Actual (Problematic) Behavior
The actual problem is that it would cause a memory leak, which we could see when testing
Expected Behavior
The async dispose should happen correctly, not reject.
Additional Context
No response
Can you elaborate why you think this causes a memory leak?
Hi,
We use Monaco editor as part of one of our components written in AngularJS.
For every of our components, we add a tag onto the scope so that we can detect if anything is left over after destroying the scope.
Part as part of our destroy, we dispose of the monaco editor, however, when we run our tests, we find tags left over, with a promise help for async.js. How we do it is we run our tests, open de dev tools, perform a gc (click few the button), then perform a heap snapshot. We then search for tag, and find leftover tags.

I hope this helps.
Louis
Can you provide steps of how to reproduce the memory leak in the playground?
I will spend some time on it and try to get the leak on the playground. It might take some time hehe.
Hey @hediet, this issue might need further attention.
@kazepreaux, you can help us out by closing this issue if the problem no longer exists, or adding more information.
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.
Happy Coding!