Repository navigation
Incremental compile panics on a failed output write, or never retries it #64875
Description
🔎 Search Terms
TS5033, Could not write file, panic, nil pointer dereference, diagnosticToStringBuilder, incremental, tsbuildinfo, up to date
🕗 Version & Regression Information
- This is the behavior in every version I tried: 7.0.2 and 7.1.0-dev.20261019.1, on Windows 11
💻 Code
tsconfig.json:
{
"compilerOptions": {
"incremental": true,
"declaration": true,
"rootDir": "src",
"outDir": "dist"
}
}src/a.ts is export const a = 1; and src/b.ts is export const b = 2;. A directory where a.js goes makes that one write fail:
mkdir -p dist/a.js
tsc -p .Then the same project without "declaration": true:
mkdir -p dist/a.js
tsc -p .
rmdir dist/a.js
tsc -b
tsc -p .🙁 Actual behavior
With declaration, tsc -p . and tsc -b panic instead of reporting the failed write:
panic: runtime error: invalid memory address or nil pointer dereference [recovered, repanicked]
...
github.com/microsoft/TypeScript/tsc/internal/ast.(*SourceFile).FileName(...)
github.com/microsoft/TypeScript/tsc/internal/ast/ast.go:2629
github.com/microsoft/TypeScript/tsc/internal/execute/incremental.diagnosticToStringBuilder(...)
github.com/microsoft/TypeScript/tsc/internal/execute/incremental/snapshot.go:411 +0x109
github.com/microsoft/TypeScript/tsc/internal/execute/incremental.(*snapshot).computeSignatureWithDiagnostics(...)
github.com/microsoft/TypeScript/tsc/internal/execute/incremental/snapshot.go:400 +0x11d
github.com/microsoft/TypeScript/tsc/internal/execute/incremental.(*emitFilesHandler).getEmitOptions.func1(...)
github.com/microsoft/TypeScript/tsc/internal/execute/incremental/emitfileshandler.go:212 +0x112
Without declaration, the first run reports error TS5033: Could not write file '…/dist/a.js': open …/dist/a.js: is a directory., and once the directory is gone no run writes dist/a.js: tsc -b exits 0 with "Project 'tsconfig.json' is up to date because newest input 'src/a.ts' is older than output 'tsconfig.tsbuildinfo'", and tsc -p . exits 1 with the same TS5033 about the removed directory.
🙂 Expected behavior
The run that cannot write dist/a.js reports TS5033 and fails, and the next run, with the path writable again, writes dist/a.js.
Additional information about the issue
The write failure's TS5033 has no file, and diagnosticToStringBuilder calls diagnostic.File().FileName() whenever the diagnostic's file is not the one being emitted. A write can fail for a reason that passes, such as another process holding the file, so the next run needs to write it again.
Activity
sunny-kavixo commentedon Oct 19, 2026
Hi YevheniiKotyrlo,
Thank you for the detailed bug report and reproduction steps.
I'm starting an independent investigation into the incremental compilation failures, focusing on both the nil-pointer panic in
diagnosticToStringBuilderand the failure to retry unsuccessful output writes.I'll reproduce the reported behavior, examine the relevant compiler paths, and explore a minimal fix with regression tests.
If I can validate a reliable solution, I'll prepare a PR referencing this issue.
Thanks!
YevheniiKotyrlo commentedon Oct 19, 2026
Love it! Thank You Putluru Sandeep (@sunny-kavixo)!
sunny-kavixo commentedon Oct 19, 2026
Thank you, YevheniiKotyrlo! I appreciate your encouragement.
I've completed the initial investigation and reproduced both reported behaviors. I'm now working on a minimal fix and regression tests for the incremental compilation paths.
I'll share an update once the solution is validated.
sunny-kavixo commentedon Oct 20, 2026
Hi YevheniiKotyrlo and TypeScript maintainers,
I've completed a focused fix for #64875 addressing both the nil-pointer panic and failed output-write retries. The regression tests and broader validation are passing.
I noticed the PR template requires an associated issue in the
Backlogmilestone. Would a maintainer be willing to triage this issue and add it toBacklogif appropriate?The patch is ready for submission, and I'll include the required AI-assistance disclosure and personally handle review feedback.
Thank you!