Skip to content

Return an API error when opened files cannot be loaded into a project - #64374

Merged
Andrew Branch (andrewbranch) merged 2 commits into
mainfrom
copilot/fix-crash-report
Sep 21, 2026
Merged

Andrew Branch (andrewbranch) merged 2 commits into
mainfrom
copilot/fix-crash-report

Conversation

Copilot AI commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Analysis

The crash reported on #64204 occurs when openFiles requests an unreadable virtual identity: ts-loader opens App.vue.ts, but its host serves App.vue. Snapshot construction proceeds without a containing project, then panics while building the response. This also reproduces with createSnapshot, not only update.

Fix

  • Validation: Check project membership after ensuring each requested file; reject invalid opens through existing client-error and snapshot-cleanup paths. Keep the response invariant assertion.
  • Coverage: Exercise sync/async creation, updates, successful retries, deleted-file reopens, and snapshot isolation.
  • Contract: Document rejection when a file cannot be loaded into a project. Correctly served virtual files remain supported; ts-loader’s filename aliasing still needs correction.

Copilot Checklist

I successfully ran the applicable command at the end of my session, and it completed without error:

  • npx hereby validate
  • npx hereby validate --api (for TypeScript API changes)
Copilot AI and others added 2 commits September 21, 2026 16:25
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>
Co-authored-by: andrewbranch <3277153+andrewbranch@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The validation uses existing error cleanup paths and has comprehensive sync and async regression coverage.

Review effort: Balanced
Findings: None

What changed in this PR

Returns a client error instead of panicking when snapshot-opened files cannot be loaded into a project.

Changes:

  • Validates project membership for opened files.
  • Documents the failure contract.
  • Adds sync and async regression coverage.
File Description
tsc/​internal/​project/​projectcollectionbuilder.go Rejects files without a project.
tsc/​internal/​api/​proto.go Documents rejection behavior.
packages/​typescript/​test/​sync/​api.test.ts Tests synchronous snapshot behavior.
packages/​typescript/​test/​async/​api.test.ts Tests asynchronous snapshot behavior.
packages/​typescript/​src/​api/​proto.generated.ts Exposes the documented API contract.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, it would be great to attach a reason to this error, but I'm afraid that might be a lot of plumbing the way things are set up right now.

@andrewbranch
Andrew Branch (andrewbranch) added this pull request to the merge queue Sep 21, 2026
Merged via the queue into main with commit 9a75076 Sep 21, 2026
30 checks passed
@andrewbranch
Andrew Branch (andrewbranch) deleted the copilot/fix-crash-report branch September 21, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

4 participants