[dev client] Debugger crashes app on breakpoint hit
erik-lissen opened this issue ยท 25 comments
Description of the bug
I managed to use the built in launch command to connect to my app that uses dev-client. The app successfully hits a breakpoint. Sometimes it crashes the app immediately, sometimes it works and halts execution. When it does stop correctly, if I try to look at variables in VSCode it crashes immediately.
To Reproduce
Connect to the app
Expected behavior
Should be able to inspect variables
Actual behavior
Crash
Additional context
There's no error in my logs, not sure how to debug this issue. If you could provide some guidance on how to debug the problem or how to give you more information I would be glad to help. Debugging does work in the chrome debugger (by pressing 'j' in terminal).
I'm using a monorepo if that makes any difference.
Same problem for us
I'm experiencing the same issue here. Was so excited about the debugger in SDK49 but can't use it.
I'm also experiencing this issue, same issue and setup as the initial issue raised, I can't seem to get it to work.
I am experiencing the same problem, using bun and expo 49.
Same Problem.
Really simple app with just one button. Crashes, when Breakpoint hit. console.log statements do work.
OS: both Windows 11 / Mac OS (Ventura)
Same problem for me
Sounds like microsoft/vscode-js-debug#1837
After some more testing I can confirm that debugging works just find by installing VS Code v1.82.2
Same issue here with Expo 49 and VSCode Expo Tools. VS Code 1.83.1 crashes on reaching breakpoints, while VS Code 1.82.3 works fine.microsoft/vscode-js-debug#1837 was apparently fixed with a change to react-native-tools - does vscode-expo perhaps need a similar update to fix this here?
And same issue here as well, crashes on reaching bound break point.
Windows 11, Node.js v 18.15.0, VS Code v 1.83.1, expo-tools v 1.2.1.
Just as ghry5 mentioned above, downgrading VS Code to v 1.82.2 works for me as well
Same issue here
MacOS Ventura
VSCode 1.85.0-insider with Expo Tools v1.2.1 (pre-release)
VSCode 1.84.0 with Expo Tools v1.0.7
I think, vscode-react-native solved the same issue by updating some code about callFunctionOn
that mentioned on the vscode-js-debug repo comment.
microsoft/vscode-react-native#2052 Issue
microsoft/vscode-react-native#2055 PR
Hey, are there any plans to fix that? Extension seems to be totally unusable right now
Same issue here with Expo 49 and VSCode Expo Tools. VS Code 1.83.1 crashes on reaching breakpoints, while VS Code 1.82.3 works fine.microsoft/vscode-js-debug#1837 was apparently fixed with a change to react-native-tools - does vscode-expo perhaps need a similar update to fix this here?
For now the best workaround is this message.
Expo did not deliver a fix for now but by downloading the version 1.82.3 of vscode
you are able to make it works :
Download page => https://code.visualstudio.com/updates/v1_82
Hi all! Sorry for the delayed response. I was unavailable due to a short break. Let me quickly address some of the questions/mentions here.
Sounds like microsoft/vscode-js-debug#1837
I think that's about right. There seems to be a change in the script that fetches debug info from within the app / scope. This script does not seem to play well with Hermes.
I think, vscode-react-native solved the same issue by updating some code about callFunctionOn that mentioned on the microsoft/vscode-js-debug#1837 (comment).
microsoft/vscode-react-native#2052 Issue
microsoft/vscode-react-native#2055 PR
Thanks for that! I'll dig into these changes and see what we can do on Expo's side.
Hey, are there any plans to fix that? Extension seems to be totally unusable right now
The extension is not just debugging, it also enhances vscode with in-editor docs about app.json
, eas.json
, and store.config.json
. That being said, debugging is an important feature of this extension and will prioritize a fix for this.
PR to fix this is in review! If you are running into this, you could use this patch with patch-package
to include the fix for SDK 49 right now.
You don't need to update the vscode-expo extension!
Reopening, patch has not been shipped yet.
PR to fix this is in review! If you are running into this, you could use this patch with
patch-package
to include the fix for SDK 49 right now.You don't need to update the vscode-expo extension!
Great! I can upgrade VSCode to the latest version again. I really like the debug toolbar shows up in the Command Center in the latest versions. I lost this when I downgraded.
For those who missed this feature:
https://code.visualstudio.com/updates/v1_83#_command-center-and-debug-toolbar
Another (temporary) workaround would be to use an Expo dev client instead of Expo Go. I'll raise this issue internally, but it is likely related to an unexpected Hermes error within Expo Go.
Even when the JS code evaluated by vscode can't be run inside Hermes, e.g. using language features not available in Hermes, it should never cause the app to crash.
@byCedric I raised the issue specifically for dev-client as it says in the title and description so not sure I understand your comment
@erik-lissen Sorry, I was in the middle of a rabbit hole there and might not have been clear.
You mentioned that there are multiple cases where the vscode debugger could crash the app, e.g. by expanding the scope of the variables, or sometimes it crashes on a single breakpoint.
The "crash on breakpoint" is caused by a JS snippet injected by vscode to fetch information about certain variables and objects. I wrote a patch for the @expo/cli
that prevents this snippet from being injected and should prevent crashing when hitting breakpoints.
Unfortunately, the CDP spec has more injection methods, and each CDP client has separate injection scripts. Expanding the scope variables, for example, uses Runtime.callFunctionOn
in vscode, but Chrome Devtools uses Runtime.compileScript
and Runtime.evaluate
. Upon investigating this deeper, we found an issue in the Hermes and the versioned React Native layers from Expo Go. In other cases, an injected JS snippet could cause a hard crash because Hermes throws an exception without it being appropriately caught. This is likely the cause of the crashes related to expanding the scope of the variables.
Using dev clients solves some of these cases, but definitely not all. Hope this makes a bit more sense than my previous comment ๐
The fix in Expo has been merged in the latest expo 49.0.18 release (or more specifically, in @expo/cli@0.10.15). I updated my project to that release and updated to the latest VS Code and everything seems fine now. Unless there is another issue elsewhere with this that has not been fix, this can probably be closed.
You are right @thully! But, we still have one more fix to merge and release (specifically for Expo Go) - expo/expo#25355
Once that's done, I'll close this issue.
After talking internally, we likely will only merge the Expo Go change into SDK 50. Closing this issue as the original issue is resolved in expo@49.0.18
.
Thanks all! We discovered a really hard-to-track bug in React Native itself due to this issue ๐ facebook/react-native#41498