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

"RangeError: Maximum call stack size exceeded" error after upgrading from 5.6.3 to 5.7.2 #60564

Open
epmatsw opened this issue Nov 22, 2024 · 6 comments

Comments

@epmatsw
Copy link

epmatsw commented Nov 22, 2024

🔎 Search Terms

"Maximum call stack size exceeded", "getContextualTypeForObjectLiteralElement", "checkNonNullExpression"

🕗 Version & Regression Information

This changed between versions 5.7.0-dev.20240930 and 5.7.0-dev.20241001

I ran into this bug upgrading from 5.6.3 to 5.7.2 and bisected to that particular release.

⏯ Playground Link

https://www.typescriptlang.org/play/?ts=5.8.0-dev.20241122#code/KYDwDg9gTgLgBAYwgOwM7xgCwJbIOZwC8cA3gFACQAJhNjABQCUplFUwMArlMixfwG0s2VADoAhgF0AXHABEcgDSsAvgG5KK5eqA

💻 Code

I don't have a narrowed code example, it just crashes when running tsc --noEmit on our whole project.

🙁 Actual behavior

RangeError: Maximum call stack size exceeded
    at getContextualTypeForObjectLiteralElement (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:71872:52)
    at getContextualTypeForObjectLiteralMethod (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:71870:12)
    at getApparentTypeOfContextualType (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:72086:58)
    at getContextualSignature (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:72485:18)
    at getContextualThisParameterType (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:71308:35)
    at tryGetThisTypeAt (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:71103:33)
    at checkThisExpression (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:71061:18)
    at checkExpressionWorker (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:79624:16)
    at checkExpression (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:79564:32)
    at checkNonNullExpression (/Users/will/.nvm/versions/node/v22.11.0/lib/node_modules/typescript/lib/_tsc.js:73599:29)

🙂 Expected behavior

No crash

Additional information about the issue

No response

@Andarist
Copy link
Contributor

According to the provided bisect information it's caused by something in this diff.

To fix this a repro case has to be provided though.

@epmatsw
Copy link
Author

epmatsw commented Nov 22, 2024

It doesn't show up in the UI for some reason, but in the console you can see an uncaught promise rejection:

Image

@Andarist
Copy link
Contributor

It shouldn't happen but I'm not entirely convinced that it's a repro case for your original problem. This crashes when calling reportNonexistentProperty so it feels like an extra repro for #60336 (that said... a new one cause your issue is pretty new and that can be reproduced with older TS versions). I assume that you've wanted to report an issue for a code that doesn't error on 5.6.3. Once we add a missing property, this repro stops crashing: TS playground

@Andarist
Copy link
Contributor

The above repro is caused by the fact that typeFromObjectLiteral calls inferExpressionType nowadays despite !canGetTypeFromObjectLiteral(objectLiteral, context). Previously it bailed out of this function and just returned false in this case.

@cgockeln42
Copy link

We have a similar stacktrace and issue. With version 5.6.3 it is working and building but with the latest 5.7.2 its failing with the following stacktrace:

node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

RangeError: Maximum call stack size exceeded
    at getJSDocType (D:\a\1\s\node_modules\typescript\lib\typescript.js:15151:22)
    at getEffectiveTypeAnnotationNode (D:\a\1\s\node_modules\typescript\lib\typescript.js:20389:91)
    at getContextualTypeForVariableLikeDeclaration (D:\a\1\s\node_modules\typescript\lib\typescript.js:75985:22)
    at getContextualTypeForObjectLiteralElement (D:\a\1\s\node_modules\typescript\lib\typescript.js:76477:69)
    at getContextualType2 (D:\a\1\s\node_modules\typescript\lib\typescript.js:76770:16)
    at getApparentTypeOfContextualType (D:\a\1\s\node_modules\typescript\lib\typescript.js:76689:120)
    at getContextualTypeForObjectLiteralElement (D:\a\1\s\node_modules\typescript\lib\typescript.js:76481:18)
    at getContextualTypeForObjectLiteralMethod (D:\a\1\s\node_modules\typescript\lib\typescript.js:76473:12)
    at getApparentTypeOfContextualType (D:\a\1\s\node_modules\typescript\lib\typescript.js:76689:58)
    at getContextualSignature (D:\a\1\s\node_modules\typescript\lib\typescript.js:77088:18)

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

3 participants