feat: restart react frontend on backend foreground service crash - #271
Open
RangerMauve wants to merge 9 commits into
Open
feat: restart react frontend on backend foreground service crash#271RangerMauve wants to merge 9 commits into
RangerMauve wants to merge 9 commits into
Conversation
When the embedded backend (the :ComapeoCore foreground service) is killed and cold-restarts, the @comapeo/ipc client in the React Native layer stays bound to the dead transport: the socket reconnects, but the client's subscription/correlation state is not rebuilt against the fresh backend. Detect that loss->ready transition in the main process and restart the React Native frontend via ProcessPhoenix, so the client and all JS state are rebuilt against the fresh backend. The FGS runs in a separate process, so it survives the restart and the relaunched app reconnects to it. ProcessPhoenix (com.jakewharton:process-phoenix) is used directly rather than via react-native-restart: the Android restart is just its ProcessPhoenix.triggerRebirth() static call, so no JS/codegen layer is pulled in.
Adds a Maestro flow that exercises the Android frontend-restart path: the :ComapeoCore FGS is killed (and cold-restarts via START_STICKY) while the React Native process stays alive, and the flow asserts the frontend restarts. - New SIMULATE_PROCESS_KILL test seam: the FGS kills its own process without stopSelf so START_STICKY cold-restarts it; gated to the e2e app package so it stays inert in production. - crashBackendForTesting() module fn + a "Crash backend (test)" button in the e2e app drive the seam. - fresh-launch indicator (visible ~10s on each JS process) is the signal that the frontend actually restarted, not just the backend recovering. - Flow is androidOnly (no-op on iOS, where Node is in-process) and is wired into the CI BrowserStack suite.
gmaclennan
requested changes
Sep 9, 2026
gmaclennan
reviewed
Sep 9, 2026
`appContext` is Expo's AppContext, not an android.content.Context, so `Intent(appContext, ...)`, `appContext.startForegroundService(...)`, and `ProcessPhoenix.triggerRebirth(appContext)` did not compile. Switch both call sites (restartFrontend + crashBackendForTesting) to `appContext.reactContext` with a null guard, matching the pattern the rest of the module already uses. Verified locally: `:comapeo-core-react-native:testDebugUnitTest` compiles and passes (161 tests, 0 failures).
Contributor
Author
|
Any clue why we're getting maestro parsing errors in the workflow? |
Contributor
Author
|
turns out the agent just made up the "androidOnly" flag. took way too long to figure that out :P |
`sleep` is not a valid Maestro command (2.7.0), which broke BrowserStack's test-suite parse. The bg->fg round-trip plus the extendedWaitUntil timeouts already provide the settle.
Wraps 'maestro check-syntax' across every maestro/*.yaml and exits non-zero on failure. Catches unknown commands (e.g. a stray 'sleep') locally before they surface in CI as an opaque BROWSERSTACK_TESTSUITE_PARSE_ERROR.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
part of #247
This lets us avoid funky resubscribe logic in our RPC layer for the edge case of Android killing the FGS on OOM (which is less likely to happen now that we have master key caching)