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

TS Server fatal error: Maximum call stack size exceeded when opening the repo #97

Closed
bartlomein opened this issue Feb 6, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@bartlomein
Copy link

Description

Once I install dependencies and open the repo in VS code, TS server crashes. This happens on workspace TS version and repo TS version

Steps to reproduce

  1. Follow all the steps from the repo to make an example application
  2. Open the repo in VS code

React Native Version

0.73.3

Affected Platforms

Other (please specify)

Output of npx react-native info

System:
  OS: macOS 14.3
  CPU: (12) arm64 Apple M2 Max
  Memory: 8.90 GB / 64.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.10.0
    path: /usr/local/bin/node
  Yarn:
    version: 3.6.4
    path: /usr/local/bin/yarn
  npm:
    version: 10.2.3
    path: /usr/local/bin/npm
  Watchman: Not Found
Managers:
  CocoaPods: Not Found
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - visionOS 1.0
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: Not Found
  Xcode:
    version: 15.2/15C500b
    path: /usr/bin/xcodebuild
Languages:
  Java: Not Found
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.3
    wanted: 0.73.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

❗️❗️❗️ Please fill in the sections below to help us diagnose the issue ❗️❗️❗️

**TypeScript Version:** 5.3.2

**Steps to reproduce crash**

1.
2.
3.

**TS Server Log**

❗️ Server logging disabled. To help us fix crashes like this, please enable logging by setting:


"typescript.tsserver.log": "verbose"


After enabling this setting, future crash reports will include the server log.

**TS Server Error Stack**

Server: `semantic`

RangeError: Maximum call stack size exceeded
at Object.scan (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:12637:16)
at nextTokenWithoutCheck (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31454:36)
at nextToken (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31464:12)
at isParenthesizedArrowFunctionExpressionWorker (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33842:20)
at speculationHelper (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:13458:20)
at Object.lookAhead (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:13491:12)
at speculationHelper (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31501:68)
at lookAhead (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31513:12)
at isParenthesizedArrowFunctionExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33824:14)
at tryParseParenthesizedArrowFunctionExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33811:22)
at parseAssignmentExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33717:29)
at parseExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33688:16)
at doOutsideOfContext (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31354:12)
at allowInAnd (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31375:12)
at parseParenthesizedExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34841:24)
at parsePrimaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34803:16)
at parseMemberExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34242:24)
at parseLeftHandSideExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34236:82)
at parseUpdateExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34211:24)
at parseUnaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34130:32)
at parseBinaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34052:25)
at parseAssignmentExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33723:18)
at parseExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33688:16)
at doOutsideOfContext (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31354:12)
at allowInAnd (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31375:12)
at parseParenthesizedExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34841:24)
at parsePrimaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34803:16)
at parseMemberExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34242:24)
at parseLeftHandSideExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34236:82)
at parseUpdateExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34211:24)
at parseUnaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34130:32)
at parseBinaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34052:25)
at parseAssignmentExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33723:18)
at parseExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33688:16)
at doOutsideOfContext (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31354:12)
at allowInAnd (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31375:12)
at parseParenthesizedExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34841:24)
at parsePrimaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34803:16)
at parseMemberExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34242:24)
at parseLeftHandSideExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34236:82)
at parseUpdateExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34211:24)
at parseUnaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34130:32)
at parseBinaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34052:25)
at parseAssignmentExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33723:18)
at parseExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33688:16)
at doOutsideOfContext (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31354:12)
at allowInAnd (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31375:12)
at parseParenthesizedExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34841:24)
at parsePrimaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34803:16)
at parseMemberExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34242:24)
at parseLeftHandSideExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34236:82)
at parseUpdateExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34211:24)
at parseUnaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34130:32)
at parseBinaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34052:25)
at parseAssignmentExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33723:18)
at parseExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33688:16)
at doOutsideOfContext (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31354:12)
at allowInAnd (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31375:12)
at parseParenthesizedExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34841:24)
at parsePrimaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34803:16)
at parseMemberExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34242:24)
at parseLeftHandSideExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34236:82)
at parseUpdateExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34211:24)
at parseUnaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34130:32)
at parseBinaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34052:25)
at parseAssignmentExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33723:18)
at parseExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33688:16)
at doOutsideOfContext (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31354:12)
at allowInAnd (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31375:12)
at parseParenthesizedExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34841:24)
at parsePrimaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34803:16)
at parseMemberExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34242:24)
at parseLeftHandSideExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34236:82)
at parseUpdateExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34211:24)
at parseUnaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34130:32)
at parseBinaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34052:25)
at parseAssignmentExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33723:18)
at parseExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33688:16)
at doOutsideOfContext (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31354:12)
at allowInAnd (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31375:12)
at parseParenthesizedExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34841:24)
at parsePrimaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34803:16)
at parseMemberExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34242:24)
at parseLeftHandSideExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34236:82)
at parseUpdateExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34211:24)
at parseUnaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34130:32)
at parseBinaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34052:25)
at parseAssignmentExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33723:18)
at parseExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33688:16)
at doOutsideOfContext (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31354:12)
at allowInAnd (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:31375:12)
at parseParenthesizedExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34841:24)
at parsePrimaryExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34803:16)
at parseMemberExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34242:24)
at parseLeftHandSideExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34236:82)
at parseUpdateExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34211:24)
at parseUnaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34130:32)
at parseBinaryExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:34052:25)
at parseAssignmentExpressionOrHigher (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33723:18)
at parseExpression (/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/node_modules/typescript/lib/tsserver.js:33688:16)

Reproducer

https://github.com/callstack/react-native-visionos

Screenshots and Videos

Screenshot 2024-02-06 at 10 31 29 AM
Screenshot 2024-02-06 at 10 32 02 AM

@giovanijfc
Copy link

Same problem here

@okwasniewski okwasniewski added the bug Something isn't working label Feb 6, 2024
@bartlomein
Copy link
Author

If I import a custom tsconfig.json and turn allowJs to false it will stop crashing. However then I get Operator '<' cannot be applied to types and such errors even though inside the tsconfig.json I have "jsx": "react-native", set

@okwasniewski
Copy link
Member

Thanks for the hint @bartlomein, I was able to reproduce it and setting allowJs to false fixes the issue. I think I have a solution for root cause of this:

Can you try adding visionos folder to "exclude" in tsconfig.json?

"exclude": [
      //...
      "visionos"
    ]

I guess that this comes from visionos building Hermes from the source and clones its repo to the visionos/Pods folder (which also contains some JS) and TS Server is trying to go through those files which leads to crash

@bartlomein
Copy link
Author

@okwasniewski Yup! that seems to have done it. Thanks so much!

@okwasniewski
Copy link
Member

okwasniewski commented Feb 7, 2024

I'm pinning this issue until we will have an upstream solution for the bug.

For now, for anyone that's struggling with this, you can replace the contents of your tsconfig.json with this:

{
  "extends": "@react-native/typescript-config/tsconfig.json",
  "exclude": [
    "visionos", // <- Add this
    "node_modules",
    "babel.config.js",
    "metro.config.js",
    "jest.config.js"
  ]
}

facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Feb 9, 2024
Summary:
Opening the VisionOS fork crashes `tsserver.js` inside VSCode because of some Pods files. This stops `tsserver` from looking at any files inside Pods

[Link to issue](callstack#97)

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[GENERAL] [ADDED] - Added a folder inside the `exclude` array inside `tsconfig`

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #42909

Reviewed By: lunaleaps

Differential Revision: D53518533

Pulled By: cipolleschi

fbshipit-source-id: 8d7819ec3ae8f0b413389157a34f49961434037f
@okwasniewski
Copy link
Member

A new version of @react-native/typescript-config (nightly) has been released. We can use it in the visionOS template from 0.74 but you can use it today in your app by changing the version. The template has this temporary workaround for now (which will be removed later).

Thanks @bartlomein for contributing to the fix 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants