-
Notifications
You must be signed in to change notification settings - Fork 37.3k
Fixes race condition where incomplete state of ViewModelLines could be observed by events fired during model access. #285602
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…e observed by events fired during model access.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a critical race condition in ViewModelLinesFromProjectedModel._constructLines() where the modelLineProjections array was cleared and rebuilt incrementally. During reconstruction, synchronous callbacks from model operations could fire and attempt to access the incomplete array, causing "Cannot read properties of undefined" errors when calling methods like getViewLineMinColumn, getViewLineContent, or getViewLineMaxColumn.
Key Changes
- Build projections in a local
newProjectionsarray instead of directly updatingthis.modelLineProjections - Atomically replace
this.modelLineProjectionsonly after all projections are built, preventing callbacks from observing partially updated state
|
@alexdima can you review this while Henning is out? The issues are among the top crashes in error telemetry as far as I can tell.
|
hediet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! However, I'm not sure it fixes these referenced issues, as I didn't see _constructLines in the stack trace.
I also don't know which event could be fired within that method.

Problem description
During _constructLines(), the modelLineProjections array was emptied (this.modelLineProjections = [])
While reconstructing (40+ lines of code), synchronous callbacks could fire from model operations
These callbacks tried to access modelLineProjections[index] which was empty/incomplete
Result: Cannot read properties of undefined (reading 'getViewLineMinColumn'|'getViewLineContent'|'getViewLineMaxColumn')
Potentially fixes the following issues
#284539
#283293
#283289
#283288
#283286
#283048
#233161
#213371
#213247
#198172
#283298
#283290
#240205
#240206
#232917
#246657
#175521
#161048
#260073