Skip to content

fix(test-driver): follow the reloaded app after a JavaScript reload - #526

Draft
adelbeke wants to merge 1 commit into
LegendApp:seth/kitchen-sink-gatefrom
adelbeke:ad/291-gate-worker-restart
Draft

adelbeke wants to merge 1 commit into
LegendApp:seth/kitchen-sink-gatefrom
adelbeke:ad/291-gate-worker-restart

Conversation

@adelbeke

Copy link
Copy Markdown
Contributor

Targets #219 (the Kitchen Sink gate). Part of #291.

Why

scripts/test-devtools.ts printed KNOWN ISSUE #291: the worker runtime did not restart after the reload. Isolated (worker) runtimes do restart after a reload. Two races in the test setup hid it.

  1. The test driver lost track of the app after a reload. The driver knows the UI has rendered by observing mounts on the React instance's surface presenter. A reload creates a new instance with its own presenter, so the driver never saw the reloaded UI mount. Its "has the app rendered?" gate (lastMount) also kept the value from before the reload. As a result, navigate delivered the deep link before the reloaded app listened for links, and the DevTools screen never opened.
    • Fix: when the main host restarts (hostDidStart:, ignoring worker hosts that forward it too), AppDelegate.mm re-attaches the observer to the new presenter and calls the new SparkTestDriverDidReload(), which resets the gate. navigate (and the other commands that wait for a settled UI) now wait for the reloaded UI.
  2. The worker's new debug target appears slightly later in /json/list than the screen shows it running. The test now polls with until(...).

The reload step now asserts the restart (PASS reload: the worker re-registered as …-4) instead of reporting it.

Evidence (Kitchen Sink dev build, M-series Mac, with #522 and #523 applied)

Setup Result of the reload step
No fix screen never shows the worker running (2/2 runs)
Driver fix only screen shows it running (4/4), target lookup misses it
Driver fix + polling PASS (5/5 runs, including 2 with the final assertion)

Not in this PR

  • An intermittent ERR_THREADED_RUNTIME_FUNCTION at the "runtime discovery" step (a new worker started right after the edit misses the added function), about 1 run in 7. Not investigated yet.

🤖 Generated with Claude Code

test-devtools.ts reported that isolated runtimes do not restart after a
reload (LegendApp#291). They do: the test could not see it.

- The driver watched mounts through the surface presenter of the React
  instance it started with. A reload creates a new instance with its own
  presenter, so the driver saw no mount of the reloaded UI, and navigate
  delivered the deep link before the reloaded app listened for links.
  The host now re-attaches the observer to the new presenter when the
  main host restarts, and the driver waits for the reloaded UI to settle.
- The worker's new debug target appears in /json/list shortly after the
  screen shows it running, so the test polls for it.

The reload step now asserts the restart instead of reporting it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant