Skip to content

Conversation

@dmitrivMS
Copy link
Contributor

@dmitrivMS dmitrivMS commented Jan 1, 2026

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

…e observed by events fired during model access.
Copilot AI review requested due to automatic review settings January 1, 2026 23:49
@dmitrivMS dmitrivMS added the editor-core Editor basic functionality label Jan 1, 2026
@dmitrivMS dmitrivMS requested a review from hediet January 1, 2026 23:49
@dmitrivMS dmitrivMS self-assigned this Jan 1, 2026
@dmitrivMS dmitrivMS enabled auto-merge January 1, 2026 23:49
@vs-code-engineering vs-code-engineering bot added this to the December / January 2026 milestone Jan 1, 2026
Copy link
Contributor

Copilot AI left a 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 newProjections array instead of directly updating this.modelLineProjections
  • Atomically replace this.modelLineProjections only after all projections are built, preventing callbacks from observing partially updated state

@bpasero bpasero requested a review from alexdima January 6, 2026 06:09
@bpasero
Copy link
Member

bpasero commented Jan 6, 2026

@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.

image

@dmitrivMS dmitrivMS modified the milestones: December 2025, January 2026 Jan 6, 2026
@dmitrivMS
Copy link
Contributor Author

Per discussion with @alexdima my change probably does not fix the root cause of these issues. I'll do more investigation to see if I can construct a solid repo for some of the scenarios and discuss with @hediet once he's back in office.

@dmitrivMS dmitrivMS assigned dmitrivMS and unassigned dmitrivMS Jan 6, 2026
@dmitrivMS dmitrivMS marked this pull request as draft January 6, 2026 14:43
auto-merge was automatically disabled January 6, 2026 14:43

Pull request was converted to draft

Copy link
Member

@hediet hediet left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

editor-core Editor basic functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants