-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix debugger detaching when restarting on Expo Go (#985)
This PR fixes issue where debugger is detached after restart, when runing Expo Go app. This is due to the fact that when reloading metro, the new instance of debugger with new websocket adress is created. This PR solves it as follows: - after running `metro.reload()` we wait for app to be ready - once it's ready, we're checking if old debug session is available - when old runtime is not available we close old debug session and start the now one - if old runtime is available, then we do nothing How to determine the old debug session is available: So there are to approches: - trying to execture something through the debugger - check if old debugger is on the list (#994) The problem with the first one is that when debuger is stale, it might just not answer, in that case we timeout after 1 sec. The problem with the second one is that sometimes there is ws target available that can't be used (Expo Go case), this the solution is not working reliably. To overcome those two problems we combined both solutions. We run both checks in `promise.any`, so: - If ping returns true, we're good (connection alive) - if checking list of ws targets returns false, we're good (connection closed) - if current ws target is on the list, we reject so `promise.any` waits for ping and ping will check that reliably after at most 1 sec ### How Has This Been Tested: **For debugger that detaches during restart i.e. expo-go test app:** - Lunch expo-go app - Test if debugger works (for example log or break point) - Restart with `Reload JS` - Wait until it restarts, and make sure the debugger is still attached (there should be also nice ui with "launching", "attaching to debugger") **For apps that debugger do not detach i.e. react-native-76** - Lunch expo-go app - Test if debugger works (for example log or break point) - Add breakpoint in https://github.com/software-mansion/radon-ide/blob/59372cc4e83d28edb2ae6f183b2f0d0a2e48eeb9/packages/vscode-extension/src/debugging/DebugSession.ts#L107 - Restart with `Reload JS` - Wait until it restarts (**it should not stop at the breakpoint**) - Make sure the debugger is still attached (the UI should be similar as above, but the "attaching debugger" will pass in the blink of an eye) |Expo Go Before|Expo Go After| |-|-| |<video src="https://github.com/user-attachments/assets/5ae32a1c-4c33-4a55-98a1-c645f4e92e59" />|<video src="https://github.com/user-attachments/assets/eca7c8c2-8806-45c7-a386-10f79dd706d7" />| |RN76 Before|RN 76 After| |-|-| |<video src="https://github.com/user-attachments/assets/e0b81615-e2f7-412a-b3e5-6f83e141b9a7" />|<video src="https://github.com/user-attachments/assets/70b6fae8-8ebe-4ba3-bc5d-141c9dc545ef" />|
- Loading branch information
1 parent
439463e
commit 2b96755
Showing
5 changed files
with
144 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters