Uncaught Error: TextModel got disposed before DiffEditorWidget model got reset
When using DiffEditor with Monaco 0.51 and the component is unmounted, the following error is thrown:
Error: TextModel got disposed before DiffEditorWidget model got reset
at u.value (diffEditorWidget.ts:327:24)
at d._deliver (event.ts:1213:13)
at d._deliverQueue (event.ts:1224:9)
at d.fire (event.ts:1248:9)
at q.dispose (textModel.ts:356:23)
...
The error does not appear with Monaco 0.50.
To Reproduce
I prepared a minimal code snippet to reproduce the issue: https://github.com/armisael/test-react-monaco-diff
Simply:
-
npm run dev - open your browser on http://localhost:3000
- open the inspector
- click on "Show editor"
- click on "Hide editor"
- see the error in console
Desktop (please complete the following information):
- OS: OSX
- Browser: Arc (chromium-based)
- Version: @monaco-editor/react 4.6.0
@armisael Do you know if this error has any real impact, or is it safe to ignore?
In our case we didn't notice any real impact, so our solution was indeed to ignore it, but I can't assume this is true for all cases.
Also, people over https://github.com/microsoft/vscode/issues/218001 had what looks like the same issue, and fixed it a couple of months ago.
@armisael @Eyal-Be could you please try to load the latest monaco-editor version via loader and see if the fix @armisael mentioned here helps? You can do something like this
Hi @suren-atoyan , that's exactly what I'm doing in the test project, have a look at:
https://github.com/armisael/test-react-monaco-diff/blob/main/src/components/MonacoDiffEditor.tsx
The error appears when using [email protected] and [email protected], but not with [email protected].
I'm not sure how to interpret the issue on https://github.com/microsoft/vscode/issues/218001 I'm afraid I can't help much
i'm experiencing the same error and in my case it is a problem indeed:
i have a nextjs react app, and a page with a several Editors and DiffEditors, which can be switched by sidebar tabs,
in case where i have 2+ DiffEditors and i switch between them a couple times – i get the mentioned error and the result looks like monaco is showing me correct text in the DiffEditor but is using a model from the previous tab' DiffEditor to highlight the diffs:
Any update to this as the issue is still there when the DiffEditor is unmounted !?
https://github.com/microsoft/vscode/issues/218001
https://github.com/microsoft/vscode/pull/222197
I managed to solve this error by setting two fields to true, as per screenshot below:
keepCurrentOriginalModel={true} keepCurrentModifiedModel={true}
Hi @suren-atoyan, is there any update on this issue?
We're still encountering this error with [email protected] and 0.52.0, particularly in Firefox where it throws visibly and disrupts the UI. We've temporarily worked around it by forcing the Monaco version to 0.50.0 using @monaco-editor/loader as suggested earlier by @armisael
While this workaround works for now, we would prefer to upgrade and stay current. Do you have any timeline or ETA for an official fix?
Thanks for your help!
Hi @suren-atoyan, is there any update on this issue?
We're still encountering this error with [email protected] and 0.52.0, particularly in Firefox where it throws visibly and disrupts the UI. We've temporarily worked around it by forcing the Monaco version to 0.50.0 using @monaco-editor/loader as suggested earlier by @armisael
While this workaround works for now, we would prefer to upgrade and stay current. Do you have any timeline or ETA for an official fix?
Thanks for your help!
have you tried this?
Hi @suren-atoyan, is there any update on this issue? We're still encountering this error with [email protected] and 0.52.0, particularly in Firefox where it throws visibly and disrupts the UI. We've temporarily worked around it by forcing the Monaco version to 0.50.0 using @monaco-editor/loader as suggested earlier by @armisael While this workaround works for now, we would prefer to upgrade and stay current. Do you have any timeline or ETA for an official fix? Thanks for your help!
have you tried this?
Yes it works. Thank you for your time
Hi @suren-atoyan, is there any update on this issue? We're still encountering this error with [email protected] and 0.52.0, particularly in Firefox where it throws visibly and disrupts the UI. We've temporarily worked around it by forcing the Monaco version to 0.50.0 using @monaco-editor/loader as suggested earlier by @armisael While this workaround works for now, we would prefer to upgrade and stay current. Do you have any timeline or ETA for an official fix? Thanks for your help!
have you tried this?
Worked for me are you able to tag as solution and maybe add to the example in README?
I managed to solve this error by setting two fields to
true, as per screenshot below:
keepCurrentOriginalModel={true} keepCurrentModifiedModel={true}
When there are many editors, will this lead to memory leaks? We should manage the textmodel by ourselves.