Repository navigation
test(apps): a paused server process and a paused host each recover, and the host runs the lost process's onDisconnect (#973) - #998
Merged
Conversation
…nd the host runs the lost process's onDisconnect (#973) Adds test/apps/host-closes-silent-consumer. Two long-lived `node --import @pyric/cli/register` processes mark themselves online, register onDisconnect().set('offline') over the remote handle's raw relay channel (the same worker-op the Kotlin, Swift and Flutter clients send), and keep an RTDB listener, against a real hosted dev server whose liveness window is shortened to 40s. SIGSTOP stands in for the half-open socket: the process stops, the kernel keeps its loopback connection open, and the host sees no close, no FIN and no frames, as from a process held at a breakpoint or an app the OS suspended. - Pausing one process: the host closes its socket after the window and its onDisconnect sets offline; the other process, which heartbeats, stays online past the window. Resumed, the paused process reports the loss, reconnects, and its listener hears a later write. - Pausing the host: the running process reports "the remote sandbox sent nothing for 45s" while the host is still paused, then reconnects and hears a write once the host resumes. The driver gains app.serverProcess(), which starts a register process without waiting for it to exit, and AppProcess.pause()/resume(). stop() continues a paused process before ending it, since a stopped process holds SIGTERM, so a failed step never leaves a stopped process behind. The native onDisconnect rows in the conformance registry name the scenario; no count changes. Run against 76438dd, main just after the ADR-0019 amendment and before #996 and #995: bun test/apps/run.ts host-closes-silent-consumer step "the host closes the silent process, so its onDisconnect sets offline" failed AssertionError [ERR_ASSERTION]: the paused process was still online 60s after it was paused (part two alone, from a local copy without the part-one steps, since the failure above ends the run before part two) step "the host is paused, and the running process notices it stopped answering" failed Error: server process 2 (consumer.mjs) did not log /pyric: (.+) at http:\/\/127\.0\.0\.1:\d+; the next op connects again/ in time Closes #973
It waits out a 40s host liveness window and the client's fixed 45s liveness timeout, so pull requests skip it and the Slow app scenarios workflow runs it.
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.
Adds the app scenario
test/apps/host-closes-silent-consumer, the integration test for #973. It pauses a realnode --import @pyric/cli/registerprocess and then the real hosted dev server, and checks that the host runs the paused process's onDisconnect and that each side reconnects.The scenario is slow (
export const slow = true), so this PR's required App scenarios job (--skip-slow) does not run it. It runs in the Slow app scenarios workflow, triggered here by theci-slow-scenarioslabel: https://github.com/davideast/pyric/actions/runs/38896696645Risk
host-closes-silent-page: pull requests skip it, and it runs on pushes to main, nightly, and on PRs labeledci-slow-scenarios.pause()usesSIGSTOP/SIGCONTon the process group, which only works on POSIX systems. Both app scenario workflows run on ubuntu.AppProcess.stop()now sendsSIGCONTbeforeSIGTERMwhen the process is paused. A stopped process holdsSIGTERM, so without this a failed step would leave a stopped process until theSIGKILL5 s later.stop()'s unbounded wait afterSIGKILLis test/apps driver: spawn fails with EBADF under concurrency, and AppProcess.stop() can then hang until the job timeout #997 and is unchanged here.The host runs a lost server process's onDisconnect, and both sides reconnect
status/frozenonline60 s after the pauseofflinewithin the 40 s windowrunning(heartbeats)runningnever noticesrunningreports "sent nothing for 45s" while the host is paused, then reconnects after it resumesThe driver can pause a process and start one without waiting for it to exit
app.serverProcess(script, args, { env })starts anode --import @pyric/cli/registerprocess and returns itsAppProcessimmediately. It never waits on the process's exit; the scenario waits on its log withwaitForLog, which has a timeout.AppProcess.pause()/resume()signal the process group, andpausedreports the state. The scenario resumes every process in afinally, and the run's teardown resumes a paused process before stopping it.The
ondisconnect-set-removerows inrtdb-kotlin.ts,rtdb-swift.tsandrtdb-flutter.tsnow name this scenario next to the host fixture. No count changes;conformance-model.test.tspasses.Implementation notes
the paused process was still online 60s after it was paused.runninglogged no loss line within 60 s.read.mjsone-shot script. The observer is a page (main.jsexposesobserver.read/write), so the scenario spawns two processes instead of one per poll. That keeps it clear of the spawn concurrency flake (test/apps driver: spawn fails with EBADF under concurrency, and AppProcess.stop() can then hang until the job timeout #997).bun test/apps/run.ts --build --only-slowpassed both slow apps locally (host-closes-silent-page 80 s, host-closes-silent-consumer 124 s, 195 s total), andbun test test/apps/selection.test.tspassed 9 of 9.scenario.tsanddriver.tswithtsc --strict.Closes #973