This repository has been archived by the owner on Nov 5, 2021. It is now read-only.
Fix error Cannot read property 'getModeId' of null #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When a monaco editor instance is created and destroyed shortly afterwards, the error 'Cannot read property 'getModeId' of null' occurs. As far as I could trace this issue, this happens because in
onModelAdd
a call tosetTimeout
is made with a delay of 500ms, which in turn calls_doValidate
. If the monaco editor instance is destroyed before the callback is called,_doValidate
tries to callmodel.getModeId()
, but model is null. The little additional null-check in this PR ensures no exception is thrown if the model cannot be determined.Unfortunately, I wasn't able to reproduce this problem using vs code playground or similar. It is easily reproducible in our angular application which uses monaco-editor@0.21.2. Here, we display a monaco editor instance within a list of editable properties on the right side of the screen. This list is re-initialized whenever the user selects a new object on the left side of the screen. If you quickly change the items selected the error occurs. I'll be happy to provide a screen recording including the Chrome dev tools console if needed.
Last but not least: Thanks for all your great work! :)