Skip to content

Conversation

@timotheeguerin
Copy link
Member

fix #8624

To prevent bad packages from corrupting the language server mock the process which is something you shouldn't be using anyway

@microsoft-github-policy-service microsoft-github-policy-service bot added the compiler:core Issues for @typespec/compiler label Sep 30, 2025
compilerHost: NodeHost,
compilerHost: {
...NodeHost,
getJsImport: (path: string) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

only doing this in the server right now but feels like this probably should just be in the NodeHost because right now the repro will let tsp compile stuck

@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 30, 2025

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/compiler@8626

commit: a4f8a5c

@github-actions
Copy link
Contributor

❌ There is undocummented changes. Run chronus add to add a changeset or click here.

The following packages have changes but are not documented.

  • @typespec/compiler
Show changes

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

const result = NodeHost.getJsImport(path);
return result;
} finally {
globalThis.process.stdin = oldProcess.stdin;
Copy link
Member Author

Choose a reason for hiding this comment

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

wrong revert

let result: any;
process.exit = (() => {
// for module that calls process.exit when being imported, create an empty object as it's exports to avoid load it again
result = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

it's better for loadJsFile to return a mock result or throw so that the caller can do something for the "bad" lib. otherwise, cache won't work for these "bad" lib and we will keep loading the "bad" lib every time unnecessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler:core Issues for @typespec/compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Importing package that make use of stdout crash language server

4 participants