[Bug] Editor throws error on dispose after upgrade from 0.51 to 0.52
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?
- [X] Not reproducible in the monaco editor playground
Monaco Editor Playground Link
No response
Monaco Editor Playground Code
No response
Reproduction Steps
No response
Actual (Problematic) Behavior
After upgrading from 0.51 to 0.52 we get an error when editor.dispose() is called. I also noticed that when I remove the onDidChangeModelContent listener we don't get the error. It seems that there is some async in here because if I dispose editor in a timeout then I don't get the error as well.
I tried our code in playground, and we couldn't reproduce which is weird too, as we don't have anything uncommon.
We dispose everything as following:
if (this.modelChangeDisposable) {
this.modelChangeDisposable.dispose(); // what editorInstance.onDidChangeModelContent returns.
}
editor.getModel().dispose();
editor.dispose();
Expected Behavior
No response
Additional Context
No response
I started seeing the same problem after upgrading to 0.52.2. Here is my stack trace, in case it helps:
async.js:219 Uncaught (in promise) Canceled: Canceled
at Delayer.cancel (https://localhost:5000/static/js/vendors-node_modules_monaco-editor_esm_vs_editor_editor_main_js.chunk.js:25592:115)
at Delayer.dispose (https://localhost:5000/static/js/vendors-node_modules_monaco-editor_esm_vs_editor_editor_main_js.chunk.js:25602:10)
at dispose (https://localhost:5000/static/js/vendors-node_modules_monaco-editor_esm_vs_editor_editor_main_js.chunk.js:34334:13)
at DisposableStore.clear (https://localhost:5000/static/js/vendors-node_modules_monaco-editor_esm_vs_editor_editor_main_js.chunk.js:34417:7)
at DisposableStore.dispose (https://localhost:5000/static/js/vendors-node_modules_monaco-editor_esm_vs_editor_editor_main_js.chunk.js:34401:10)
at WordHighlighter.dispose (https://localhost:5000/static/js/vendors-node_modules_monaco-editor_esm_vs_editor_editor_main_js.chunk.js:177966:19)
at WordHighlighterContribution.dispose (https://localhost:5000/static/js/vendors-node_modules_monaco-editor_esm_vs_editor_editor_main_js.chunk.js:178017:29)
at dispose (https://localhost:5000/static/js/vendors-node_modules_monaco-editor_esm_vs_editor_editor_main_js.chunk.js:34334:13)
at DisposableMap.clearAndDisposeAll (https://localhost:5000/static/js/vendors-node_modules_monaco-editor_esm_vs_editor_editor_main_js.chunk.js:34576:7)
at DisposableMap.dispose (https://localhost:5000/static/js/vendors-node_modules_monaco-editor_esm_vs_editor_editor_main_js.chunk.js:34566:10)
We recently hit this as well and had to downgrade all the way to 0.47.0 due to a few issues. This one seems to be caused by the delayer in async.js throwing an uncaught cancel in a promise. Not sure why these are unguarded cancellations that throw outside the monaco boundary. We patched the library to catch these and do nothing, but more investigation should be needed for a resolution to this
also encountered this problem in e2e-tests where we are frequently changing tabs
I also encountered this error going from 0.51.0 to 0.52.0, but now I don't see it anymore with 0.54.0. I can't track down the change that might have fixed it, though. I'm guessing it was a change in monaco-editor-core.
Anyway, maybe someone else can confirm whether 0.54.0 is indeed a fix?
I tried updating a project that uses Monaco to 0.54.0 and still got these errors 😞
I also experience this issue after upgrade 0.51.0 -> 0.54.0.