Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Infinite recursion in TS worker #4802

Open
1 of 2 tasks
catloversg opened this issue Jan 15, 2025 · 0 comments
Open
1 of 2 tasks

[Bug] Infinite recursion in TS worker #4802

catloversg opened this issue Jan 15, 2025 · 0 comments

Comments

@catloversg
Copy link

Reproducible in vscode.dev or in VS Code Desktop?

  • Not reproducible in vscode.dev or VS Code Desktop

Reproducible in the monaco editor playground?

Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.52.2#XQAAAAJtAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwzdYgm_1uhs0-3YGTBOsVJ4S4FwfCDQb5-2uUHXTVAefbVSd9IzaZ_vv9VR9KugsKimARHSWlrTPOQHROITHxmAevjJc6KddXWSN1sNwo5JNIgnYWKVmhb0B1SfnroyskXT-0iPN9Jt1ESDDhIFdl9bHkBkOA5r_rmys3ebjP0E59AKwWFt5EBjYnSrRhXL7kWpFwHklYQ1hQUn91POVdA_jOUWtLDn3wCOoajEAmWD58rw5EDD5f2ooMfBxDBAf7mH6cCx3rmhaggrs9a7igEnEmz8gXYmi1SLP36zjlnshLlgjSTmr_6Garow

Monaco Editor Playground Code

const value = /* set from `myEditor.getModel()`: */ `function hello() {
	for (let foo of foo) { foo(); bar; };
}`;

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
	value,
	language: "javascript",
	automaticLayout: true,
});

Reproduction Steps

Open the playground link and check the developer console.

Image

Uncaught (in promise) RangeError: Maximum call stack size exceeded
    at isDeclarationWithExplicitTypeAnnotation (tsWorker.js:73813:55)
    at getExplicitTypeOfSymbol (tsWorker.js:73830:17)
    at getTypeOfDottedName (tsWorker.js:73862:22)
    at getExplicitTypeOfSymbol (tsWorker.js:73835:38)
    at getTypeOfDottedName (tsWorker.js:73862:22)
    at getExplicitTypeOfSymbol (tsWorker.js:73835:38)
    at getTypeOfDottedName (tsWorker.js:73862:22)
    at getExplicitTypeOfSymbol (tsWorker.js:73835:38)
    at getTypeOfDottedName (tsWorker.js:73862:22)
    at getExplicitTypeOfSymbol (tsWorker.js:73835:38)

Actual (Problematic) Behavior

An uncaught error is thrown.

Expected Behavior

No uncaught error.

Additional Context

We use monaco in our game to provide an in-game code editor. A player reported a problem with the in-game editor. In our game, we have a global exception handler. When monaco throws this uncaught error, an error popup is shown.

The MRE uses the player-provided script. I know that for (let foo of foo) { foo(); bar; }; is not valid JS code. Another example:

const a = [() => { }];
const b = 0;
for (const a of a) { a(); b }

This is still not valid JS code (ReferenceError: Cannot access 'a' before initialization), but having an uncaught error is unexpected.

It looks like that monaco is trying to "diagnose" the provided code, and this error is thrown by the TS worker. I'm not sure if this problem should be reported here or at https://github.com/microsoft/TypeScript (the infinite recursion is in https://github.com/microsoft/TypeScript/blob/main/src/compiler/checker.ts).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant