GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing github.com — fix(client): wait for service shutdown before restart by kitlangton · Pull Request #50042 · anomalyco/opencode Conversation
|
| During shutdown | Before | After |
|---|---|---|
| Original exits gracefully | Waits for exit | Same |
| Registration disappears; original remains alive | Returns after grace period | Escalates and waits for original exit |
| Successor registers before the final cleanup read; original remains alive | Returns while original survives | Stops original; preserves the observed successor and its registration |
This diagram shows the deliberately forced fixture sequence, including a successor registering while the original still holds its listener:
sequenceDiagram
participant C as Client stop()
participant A as Original process A
participant R as Registration
participant B as Successor B
C->>R: Verify original instance A
C->>A: SIGTERM
A->>R: Remove A's registration
Note over A: Fixture keeps A's listener open
B->>R: Register B on another port
alt Before
C->>R: Registration no longer describes A
Note over C,A: stop() returns while A is alive
else After
C->>A: SIGKILL after existing grace period
A-->>C: Original process exits
C->>R: Preserve registration belonging to B
Note over C,B: stop() succeeds; B remains healthy
end
Evidence boundary: current server code closes its listener before running its returned registration cleanup. These tests force early unregister to establish the client's stop contract; they do not establish that normal current server teardown creates this sequence, or attribute all reported startup timeouts to it.
Separate confirmed cleanup race: if cleanup reads the original record, a successor publishes, and the old cleanup then removes the shared path, it can delete the successor's registration. Adversarial real-filesystem tests reproduce this in both client variants at this PR's head, as well as in the server registration cleanup. This PR's successor test covers publication before the cleanup read; it does not establish atomic successor preservation. The publication/removal protocol needs a separate repair.
Both Effect and Promise clients run real child-process/socket regressions:
SIGTERM but retains its listener. stop() must wait until its PID is gone and the old port can be rebound.stop() must finish stopping the original while preserving the successor's full registration, live PID, and healthy HTTP endpoint.SIGKILL (POSIX): the child's parent never reaps it, so SIGKILL leaves a zombie that still answers kill(pid, 0). stop() must fail after both grace periods with Server process <pid> is still running rather than hang or report success.For the successor case, the fixture publishes an explicit post-unregister barrier. The test confirms the successor registered while the original was still alive; it does not rely on an arbitrary sleep.
| Same successor tests | Result |
|---|---|
| Pre-fix registration guard restored | 2 failed: original PID was still alive after stop() returned |
| Fixed implementation | 2 passed per run: original gone, old port reusable, successor healthy |
This PR owns completion of a client-requested stop, including the stop used during version replacement. #50782 handles transient bind recovery; #50784 preserves startup errors. Each has its own reproducer.
cd packages/client bun run test test/service.test.ts test/promise-service.test.ts -t 'preserving a newly registered successor' bun run test test/service.test.ts test/promise-service.test.ts --rerun-each 3 cd ../.. bun run check bunx prettier --check packages/client/test/fixture/service.ts packages/client/test/service.test.ts packages/client/test/promise-service.test.ts
v2 00738c5b2d: the six stop tests pass across three runs (18/18); full root lint/typecheck passes. Four unrelated generated-client tests (file.write) fail on v2 itself, with or without this change.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
6e2b228 to
9e91aee
Compare
4481b5b to
ec36e60
Compare
ec36e60 to
1d0e1aa
Compare
1d0e1aa to
83436da
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.