Skip to content

API server panics in acquireConfigForFile when opening a JS file a tsconfig does not include #65054

Open

Description

🔎 Search Terms

createSnapshot panic, acquireConfigForFile, configFileRegistryBuilder, SyncMapEntry ChangeIf nil pointer, typescript/sync openFiles .mjs .js inferred project

🕗 Version & Regression Information

  • This changed between versions 7.0.2 and 7.1.0-beta
  • It still reproduces on 7.1.0-dev.20261027.1 and 7.1.0-dev.20261029.1

⏯ Playground Link

No response

💻 Code

mkdir repro && cd repro
npm install typescript@7.1.0-beta
echo '{}' > tsconfig.json
echo 'export const a = 1' > w.mjs
node probe.mjs
// probe.mjs
import { API } from 'typescript/sync'
const api = new API({ cwd: process.cwd() })
api.createSnapshot({ openFiles: [process.cwd() + '/w.mjs'] })
api.close()

macOS arm64, Node 24.

🙁 Actual behavior

The API server crashes:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0]

github.com/microsoft/TypeScript/tsc/internal/project/dirty.(*SyncMapEntry[...]).ChangeIf(...)
	tsc/internal/project/dirty/syncmap.go:128
github.com/microsoft/TypeScript/tsc/internal/project.(*configFileRegistryBuilder).acquireConfigForFile(...)
	tsc/internal/project/configfileregistrybuilder.go:319
github.com/microsoft/TypeScript/tsc/internal/project.(*configFileRegistryBuilder).findOrAcquireConfigForFile(...)
	tsc/internal/project/configfileregistrybuilder.go:135
github.com/microsoft/TypeScript/tsc/internal/project.(*ProjectCollectionBuilder).findOrCreateDefaultConfiguredProjectWorker.func2(...)
	tsc/internal/project/projectcollectionbuilder.go:1108
github.com/microsoft/TypeScript/tsc/internal/core.BreadthFirstSearchParallelEx[...].func1-range1.1(...)
	tsc/internal/core/bfs.go:115

🙂 Expected behavior

The JS file opens in the inferred project (/dev/null/inferred), as it does when there is no tsconfig, and as 7.0.2 (typescript/unstable/sync, updateSnapshot) did with this exact layout.

Additional information about the issue

  • The same thing happens with .js, and with the JS file one or two directories below the tsconfig.
  • With no tsconfig, the file opens in /dev/null/inferred as expected.
  • If a .ts file the tsconfig includes sits in the same directory as the JS file, it also opens fine.

We hit this in a repository validator that opens every source file in a checkout, including stray .mjs and .cjs build scripts that no tsconfig includes.

Activity

  1. ycmjason commented on Oct 30, 2026

    @ycmjason

    Same panic (acquireConfigForFile → SyncMapEntry.ChangeIf) with .ts files too. It seems to trigger whenever the nearest tsconfig.json matches no files of its own and doesn't include the opened file, regardless of extension:

    nearest tsconfig.json opened file 7.0.2 7.1.0-beta / 7.1.0-dev.20261030.1
    {"files":[],"references":[{"path":"./a"}]} x.ts (also scripts/x.ts) inferred panic
    {"files":[]} x.ts inferred panic
    {"include":["src"]}, src/ empty x.ts inferred panic
    {"include":["src"]}, src/a.ts exists x.ts inferred inferred
    {"files":["a.ts"],"references":[{"path":"./a"}]} x.ts inferred inferred

    The first row is a common layout: a solution-style root tsconfig with a stray root file such as vitest.config.ts.

    mkdir repro && cd repro
    npm install typescript@7.1.0-beta
    echo '{"files":[]}' > tsconfig.json
    echo 'export const x = 1' > x.ts
    node probe.mjs
    // probe.mjs
    import { API } from 'typescript/sync'
    const api = new API({ cwd: process.cwd() })
    api.createSnapshot({ openFiles: [process.cwd() + '/x.ts'] })
    api.close()

    For comparison, the LSP server (tsc --lsp --stdio) handles didOpen and hover for all of these layouts without crashing. Only the API's createSnapshot({ openFiles }) panics.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions