Repository navigation
Fix API server panic when opening a JS file that a tsconfig does not include - #65436
Draft
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
Draft
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 3 commits into
Conversation
…me snapshot Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix API server panics in acquireConfigForFile for JS files
Fix API server panic when opening a JS file that a tsconfig does not include
Nov 11, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Opening a
.js/.mjsfile through the API panics with a nil dereference inacquireConfigForFile→SyncMapEntry.ChangeIfwhen the nearest tsconfig includes no files. With the fix, the file opens in the inferred project, as it did in 7.0.2.Root cause
HandleAPIRequestlooks up the config for each opened file twice in the same builder, with a cleanup in between:OpenFilespass: acquires the tsconfig. There are no root files, so no project retains it, and API-opened files don't retain it either.cleanupConfiguredProjects: deletes the unretained entry from the builder'sdirty.SyncMap.EnsureFilespass: acquires the same tsconfig again.LoadOrStorereturns(nil, false)for a key deleted earlier in the builder, and the caller dereferences nil.A later
updateSnapshotthat opens another stray JS file hits the same path throughLoadOrStore's base-map branch.Changes
dirty.SyncMap.LoadOrStoreReplacingDeleted(new): likeLoadOrStore, but if the key was deleted earlier in the builder, it stores the new value in that entry and returns it instead of nil.LoadOrStoreis unchanged:snapshotfsrelies on its nil return to keep files deleted in a snapshot from being re-cached.configFileRegistryBuilder:acquireConfigForFile,acquireConfigForProjectandupdateExtendingConfigsuse the new method. A config thatCleanupremoved earlier in the same snapshot is recreated and parsed again.Tests
TestOpenFileNotIncludedByConfigOpensInInferredProject(internal/api):w.mjsnext to the tsconfig andsrc/nested/w.jstwo levels below it;updateSnapshotto open a second stray.cjs;TestSyncMapLoadOrStoreDeletedKey(internal/project/dirty): checks both lookup methods on deleted base keys and deleted added keys, and checks the finalized result.Not addressed
findOrCreateProject→configuredProjects.LoadOrStorehas the same "deleted earlier in this builder returns nil" behavior. Its callers treat nil as "not found", and this issue's steps don't reach it.