Skip to content

Fix race when copying lazy computed values for updateProgram#2702

Merged
jakebailey merged 3 commits intomainfrom
ataRace
Feb 10, 2026
Merged

Fix race when copying lazy computed values for updateProgram#2702
jakebailey merged 3 commits intomainfrom
ataRace

Conversation

@sheetalkamat
Copy link
Copy Markdown
Member

Fixes #2275

Comment thread internal/compiler/program.go Outdated
Copy link
Copy Markdown
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

Fixes a reported data race (#2275) in the TypeScript-go compiler’s Program cloning path (updateProgram/UpdateProgram) by making certain lazily computed caches safe to copy across program updates.

Changes:

  • Introduced a generic lazyValue[T] helper to safely manage lazily computed cached values with a “try-get-if-initialized” path.
  • Updated Program to store unresolvedImports and knownSymlinks using lazyValue, and adjusted GetUnresolvedImports/GetSymlinkCache accordingly.
  • Modified UpdateProgram to copy only fully-initialized cached values for these fields, avoiding concurrent reads of partially initialized state.

Comment thread internal/compiler/program.go Outdated
Comment thread internal/compiler/program.go Outdated
@jakebailey jakebailey added this pull request to the merge queue Feb 10, 2026
Merged via the queue into main with commit cfc9b72 Feb 10, 2026
20 checks passed
@jakebailey jakebailey deleted the ataRace branch February 10, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Race condition detected between program updates and ATA(?)

3 participants