Skip to content

[api] Leave a config out of its own extended source files - #64755

Open
Christopher Plieger (cplieger) wants to merge 1 commit into
microsoft:mainfrom
cplieger:fix-api-extends-cycle-hang
Open

Christopher Plieger (cplieger) wants to merge 1 commit into
microsoft:mainfrom
cplieger:fix-api-extends-cycle-hang

Conversation

@cplieger

Copy link
Copy Markdown
Contributor

When an opened config's extends chain cycles back to it, parseConfig lists the config in its own ExtendedSourceFiles. It gets there through the edge that closes the cycle, or through a cached extended config whose list was built while another project was opened. The project registry walks that list in updateExtendingConfigs while it holds the config's own entry lock, so LoadOrStore waits on that lock and createSnapshot never returns.

Impact: one circular extends in a repository makes createSnapshot hang with no error, where tsc -p reports TS18000 and exits 2 at once, so an analyzer on the API stalls on that repository instead of reporting what is wrong with it.

parseConfig now skips the config's own path when it assembles ExtendedSourceFiles, compared by PathKey as the circularity check does. Every other config in the chain stays in the list, so watching and cache invalidation see the same dependencies, and TS18000 is reported as before. Strada also lists the config in this case, but nothing there walks the list under that config's lock.

TestOpenProjectsWithCircularExtendsReportCircularity opens p1 and then p2 in one session. Both extend shared/base.json, which extends p2, so p2 reaches itself through the edge that closes the cycle and through the base.json entry cached while p1 was opened. It expects TS18000 as the only config file parsing diagnostic of p2, and on main it times out after 10 seconds on each of 20 runs. With a tsc built from this branch, the reproduction in the issue returns and reports TS18000.

TS18000 still prints its {0} placeholder unfilled, which has a separate cause and is left out of this change.

I met this while building deadset-ts, the TypeScript analyzer of deadset, on the TypeScript 7 API. That work hit a small set of related defects, which is why a few reports come from me.

An AI coding agent wrote this patch. I have read, built and tested it and will handle the review.

  • There is an associated issue in the Backlog milestone (required)
  • Code is up-to-date with the main branch
  • You've successfully run npx hereby test
  • You've successfully run npx hereby lint
  • You've successfully run npx hereby check:format
  • There are new or updated tests validating the change

Fixes #64754

Copilot AI balanced review requested due to automatic review settings October 12, 2026 22:00
@typescript-automation typescript-automation Bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 12, 2026

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.

🟢 Approval recommended

The focused fix preserves other extended dependencies and the regression test covers the reported cached-chain deadlock.

0 open findings

What changed in this PR

Prevents API snapshot deadlocks when a configuration’s extends chain is circular.

Changes:

  • Excludes a config’s own canonical path from ExtendedSourceFiles.
  • Adds an API regression test covering cached circular extends chains and TS18000.
File Description
tsc/​internal/​tsoptions/​tsconfigparsing.go Filters self-references from extended config dependencies.
tsc/​internal/​api/​session_apistate_test.go Verifies snapshot creation completes and reports circularity.

🧠 Review effort: Balanced


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

codes = append(codes, diagnostic.Code)
}
assert.DeepEqual(t, codes, []int32{18000})
case <-time.After(10 * time.Second):

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.

There's no reason to do this in a test, since the test would just exit on the global timeout, no? Or maybe just use synctest if you want to drive it?

This branch has not been deployed

No deployments
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

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

[api] createSnapshot never returns when the opened tsconfig.json has a circular extends

3 participants