Skip to content

fix: share in-flight getSourceFile requests in native-preview async API (#65503) - #65511

Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
microsoft:mainfrom
zhengdaodeguL:fix/concurrent-getsourcefile-cache-stampede-65503
Open

刘亦达 (zhengdaodeguL) wants to merge 1 commit into
microsoft:mainfrom
zhengdaodeguL:fix/concurrent-getsourcefile-cache-stampede-65503

Conversation

@zhengdaodeguL

Copy link
Copy Markdown

Fixes #65503

Concurrent Program.getSourceFile calls for the same file each fetched the whole file from the server instead of sharing one in-flight request. This mirrors the in-flight promise-sharing pattern already used by getSourceFileMetadata: getSourceFile and getSourceFileByPath now share a per-path promise held in a Program-local map, removed in finally so a failed fetch is retried on the next call. Retained-cache hits still return before consulting the in-flight map.

Verification

  • New regression test concurrent getSourceFile calls share an in-flight request (10 overlapping calls against a deferred fetch): 1 underlying request. Before the fix the same test observes 10 requests.
  • Targeted test command passes: node --conditions @typescript/source --test --test-name-pattern='concurrent getSourceFile calls share an in-flight request' ./test/async/api.test.ts (1 pass, 0 fail).
  • npm run -w @typescript/typescript build passes; npx hereby check:format passes.
  • Not run locally: full npx hereby test (requires building the native compiler with Go, unavailable in this environment) and npx hereby lint. The full API integration tests need built/local/tsc and cannot launch here; the targeted regression test does not need it.

Checklist

Copilot AI balanced review requested due to automatic review settings November 15, 2026 12:33
@typescript-automation typescript-automation Bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Nov 15, 2026
@github-project-automation github-project-automation Bot moved this to Not started in PR Backlog Nov 15, 2026
@zhengdaodeguL

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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 was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@typescript-automation typescript-automation Bot added For Backlog Bug PRs that fix a backlog bug and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Nov 17, 2026

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 Backlog Bug PRs that fix a backlog bug

Projects

Status: Not started

Development

Successfully merging this pull request may close these issues.

API client: concurrent Program.getSourceFile calls for one file stampede the cache, each fetching the file whole

2 participants