Skip to content

fix(language-server): prevent stack overflow with project references containing non-TS files#16827

Merged
matthewp merged 3 commits into
mainfrom
fix-16817
May 26, 2026
Merged

fix(language-server): prevent stack overflow with project references containing non-TS files#16827
matthewp merged 3 commits into
mainfrom
fix-16817

Conversation

@matthewp

Copy link
Copy Markdown
Contributor

Fixes #16817

When a tsconfig uses project references that include .vue or .svelte files, TypeScript's getOutputDeclarationFileName returns the input path unchanged (since changeExtension doesn't recognize these extensions). This creates self-referencing entries in the redirect maps (Hello.vueHello.vue), causing infinite recursion in findSourceFile.

The fix provides getParsedCommandLine on the language service host, which is TypeScript's official hook for customizing how referenced tsconfigs are parsed. Our implementation parses them normally but filters .vue/.svelte/.astro files from the file list, preventing the self-referencing redirect entries. Project references remain fully functional for all standard TS/JS files.

@changeset-bot

changeset-bot Bot commented May 21, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b382913

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@astrojs/language-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@matthewp matthewp added pr preview Apply this label to a PR to generate a preview release and removed pr preview Apply this label to a PR to generate a preview release labels May 21, 2026
@matthewp matthewp added pr preview Apply this label to a PR to generate a preview release and removed pr preview Apply this label to a PR to generate a preview release labels May 21, 2026
@github-actions github-actions Bot removed the pr preview Apply this label to a PR to generate a preview release label May 21, 2026
@pkg-pr-new

pkg-pr-new Bot commented May 21, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@astrojs/language-server@16827

commit: b4b57b2

@matthewp matthewp marked this pull request as ready for review May 21, 2026 20:57
@matthewp matthewp added the fix verified Reporter confirmed the triage bot fix works label May 21, 2026
@matthewp

Copy link
Copy Markdown
Contributor Author

Verified by the reporter: #16817 (comment)

Comment thread packages/language-tools/language-server/src/core/index.ts
const mockHost = {
getScriptFileNames: () => [],
getCompilationSettings: () => ({}),
getProjectReferences: () => [{ path: './tsconfig.app.json' }],

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.

Shouldn't the tests verify things against vue/svelte/astro files?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it has to read the file system to properly test that. so it would need a fixture. Happy to add one if you'd like.

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.

No, I just don't understand the test 😅 but I also don't understand the codebase, so it's fine

Comment thread packages/language-tools/language-server/src/core/index.ts Outdated
Comment thread packages/language-tools/language-server/src/core/index.ts Outdated

@Princesseuh Princesseuh left a comment

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.

I don't know if it's the proper fix or not, I guess this is something that is caused by a patch in Volar already? But if this works I'm fine with it, not the first time we do these kinds of patches (but perhaps the last one in this upcoming Go TS world)

@matthewp matthewp merged commit 90ee151 into main May 26, 2026
27 checks passed
@matthewp matthewp deleted the fix-16817 branch May 26, 2026 12:02
@astrobot-houston astrobot-houston mentioned this pull request May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix verified Reporter confirmed the triage bot fix works

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Maximum call stack size exceeded from VSCode extension

3 participants