microsoft / vscode-react-native

VSCode extension for React Native - supports debugging and editor integration
https://marketplace.visualstudio.com/items?itemName=vsmobile.vscode-react-native
Other
2.62k stars 263 forks source link

[Bug] React Native Tools (v2023.11.1220) failure: error code 702 #2068

Closed rivaros closed 9 months ago

rivaros commented 9 months ago

🐛 What is the bug? How can we reproduce it?

Getting the following error in "React Native" output. Looks like extension fails to initialize on the project [Error] Failed to activate the React Native Tools extension (error code 702)

Important: Stable version v1.12.1 works good

Another syndrom:

When trying to attach/debuggetting error:

Screenshot 2023-11-13 at 4 03 35 PM

Launch.json seems ok:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug iOS Hermes iOS17",
            "request": "launch",
            "type": "reactnativedirect",
            "cwd": "${workspaceFolder}",
            "platform": "ios",
            "runArguments": ["--simulator", "iPhone 14 (17.0)"]
        },
        {
            "name": "Attach to Hermes application - Experimental",
            "request": "attach",
            "type": "reactnativedirect",
            "cwd": "${workspaceFolder}"
        }
    ],
}

Environment

Please tell us about your system and your project:

➜  rn0.72.6 npx react-native doctor
Common
 ✓ Node.js - Required to execute JavaScript code
 ✓ yarn - Required to install NPM dependencies
 ✓ Watchman - Used for watching changes in the filesystem when in development mode

Android
 ✖ Adb - No devices and/or emulators connected. Please create emulator with Android Studio or connect Android device.
 ✓ JDK - Required to compile Java code
 ✓ Android Studio - Required for building and installing your app on Android
 ✓ Android SDK - Required for building and installing your app on Android
 ✓ ANDROID_HOME - Environment variable that points to your Android SDK installation

iOS
 ✓ Xcode - Required for building and installing your app on iOS
 ✓ Ruby - Required for installing iOS dependencies
 ✓ CocoaPods - Required for installing iOS dependencies
 ✓ ios-deploy - Required for installing your app on a physical device with the CLI
 ✖ .xcode.env - File to customize Xcode environment
  System:
    OS: macOS 13.6
    CPU: (10) arm64 Apple M1 Pro
    Memory: 256.73 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.14.2/bin/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
    pnpm: 6.11.0 - ~/.nvm/versions/node/v16.14.2/bin/pnpm
    Watchman: 2023.11.06.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.14.2 - .bin/pod
    Composer: 1.7.1 - /usr/local/bin/composer
    Homebrew: 4.1.19 - /opt/homebrew/bin/brew
    pip2: 20.3.4 - ~/.pyenv/shims/pip2
    pip3: 23.3.1 - /opt/homebrew/bin/pip3
    RubyGems: 3.1.6 - /Users/ross/.rbenv/shims/gem
  Utilities:
    Make: 3.81 - /usr/bin/make
    GCC: 14.0.3 - /usr/bin/gcc
    Git: 2.42.0 - /opt/homebrew/bin/git
    Clang: 14.0.3 - /usr/bin/clang
    Curl: 8.4.0 - /opt/homebrew/opt/curl/bin/curl
  Servers:
    Apache: 2.4.57 - /opt/homebrew/bin/apachectl
    Nginx: 1.25.2 - /opt/homebrew/bin/nginx
  Virtualization:
    Docker: 23.0.5 - /usr/local/bin/docker
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
    Android SDK:
      API Levels: 28, 29, 30, 31, 32, 33, 34, 34
      Build Tools: 30.0.2, 30.0.3, 31.0.0, 32.0.0, 32.1.0, 33.0.0, 33.0.1, 34.0.0
      System Images: android-28 | Android TV Intel x86 Atom, android-28 | Google ARM64-V8a Play ARM 64 v8a, android-29 | Android TV Intel x86 Atom, android-29 | Google Play ARM 64 v8a, android-30 | ARM 64 v8a, android-30 | Google Play ARM 64 v8a, android-31 | Google Play ARM 64 v8a, android-32 | Google APIs ARM 64 v8a, android-32 | Google Play ARM 64 v8a, android-33 | Google APIs ARM 64 v8a, android-33 | Google Play ARM 64 v8a
  IDEs:
    Android Studio: 2022.3 AI-223.8836.35.2231.10811636
    VSCode: 1.84.2 - /usr/local/bin/code
    Vim: 9.0 - /usr/bin/vim
    Xcode: 14.3.1/14E300c - /usr/bin/xcodebuild
  Languages:
    Bash: 3.2.57 - /bin/bash
    Go: 1.20.7 - /usr/local/go/bin/go
    Java: 17.0.6 - /usr/bin/javac
    Perl: 5.30.3 - /usr/bin/perl
    PHP: 7.0.33 - /opt/homebrew/opt/php@7.0/bin/php
    Protoc: 24.3 - /opt/homebrew/bin/protoc
    Python: 2.7.18 - /Users/ross/.pyenv/shims/python
    Python3: 3.11.6 - /opt/homebrew/bin/python3
    Ruby: 2.7.5 - /Users/ross/.rbenv/shims/ruby
  Databases:
    MySQL: 12.6 - /opt/homebrew/opt/mysql-client/bin/mysql
    SQLite: 3.39.5 - /usr/bin/sqlite3
  Browsers:
    Safari: 16.6
EzioLi01 commented 9 months ago

Hey @rivaros , are you using workspace in vscode for your project? I think I have seen this error in another issue, it should be related to new feature we added.

Also, please try to uninstall extension and delete extension folder from /Users/XXX/.vscode/extensions/, and install it again to see if it can be resolved.

rivaros commented 9 months ago

@EzioLi01 Deleting extension folder has no effect. On fresh install it spits the error again. And yes, am using workspace.

It looks schematically like this

{
    "folders": [
        {
            "name": "lib",
            "path": "<path to some lib>"
        },
        {
            "path": "mobile"
        },
        {
            "path": "mobile-ci"
        },
        {
            "path": "mobile-web"
        }
    ]
}

mobile folder contains react native project. As I said, prod version of extension works good.

rivaros commented 9 months ago

@EzioLi01 Yes, when I use "Open Folder..." to directly open the react native project it works. But still it's pretty much unusable without workspaces, because usually when working on a project you also have backend and ci stuff which resides in different folders.

rivaros commented 9 months ago

Also getting the following error

Failed to fetch source map http://x.x.x.x:8081/index.map?platform=ios&dev=true&minify=false&inlineSourceMap=false&modulesOnly=false&runModule=true&app=com.app.name: remote fetches not permitted

It kinda works even with this error. Should I be concerned about it as well?

EzioLi01 commented 9 months ago

If this error is not blocking your debugging, I think we can ignore it so far. For the error, it's related to a new feature that is not available on prod version.
Is it possible to provide your whole workspace settings file .code-workspace for the investigation? It may have format issue in JSON file, I think.

rivaros commented 9 months ago

@EzioLi01 probably you are parsing.code-workspace with JSON.parse. It is JSONP file, which can have comments.

https://code.visualstudio.com/docs/editor/multi-root-workspaces#_workspace-file-schema

Could it be that it's failing because of comments in workspace file?

EzioLi01 commented 9 months ago

@EzioLi01 probably you are parsing.code-workspace with JSON.parse. It is JSONP file, which can have comments.

https://code.visualstudio.com/docs/editor/multi-root-workspaces#_workspace-file-schema

Could it be that it's failing because of comments in workspace file?

Nice catch! I think this should be the root cause, I have missed it in feature. Will do fixing for it with priority, any updates will comment here. Appreciating this great issue!

EzioLi01 commented 9 months ago

Hey @rivaros , could you please install and try on this .vsix file to see if it's resolved? Please uninstall existing extension and delete react-native-tools folder from /.vscode/extensions to prevent any conflict. Thank you!

Any issue please let me know.

vscode-react-native-1.12.2.vsix.zip

rivaros commented 9 months ago

Hi @EzioLi01 ,

Concerning VSIX - it works good with my project now 👍 Many thx. There is still a minor issue - it crashes on trailing commas, but this is well - edge case.

EzioLi01 commented 9 months ago

Hi @EzioLi01 ,

Concerning VSIX - it works good with my project now 👍 Many thx. There is still a minor issue - it crashes on trailing commas, but this is well - edge case.

Thanks @rivaros for the confirm, please using this for debugging. I will send PR for the fixing, once PR merged, it will be available on nightly version.

I will try to improve comma issue as well, maybe add stripJsonTrailingComma function or add some useful message for it.