Repository navigation
fix(service): bound AmicodeServiceServer.stop() — closeAllConnections after a 2s grace (#1707) - #1708
Closed
aarontrowbridge wants to merge 1 commit into
Closed
aarontrowbridge wants to merge 1 commit into
aarontrowbridge wants to merge 1 commit into
Conversation
… after a 2s grace (#1707) A bare server.close() waits for every open keep-alive socket to END — the hub frontdoor holds long-lived pooled backend sockets to the service origin plus SSE fan-outs, so stops parked the unit in 'deactivating' anywhere between 6 seconds and systemd's SIGKILL (three wedged hub stops on 2026-10-04, each an outage window; hub-restart.sh blocks on them). The engine kill was already bounded (SIGTERM -> 3s -> SIGKILL); the service close was the unbounded leg. stop() now: close() first (no new accepts), a 2s grace for in-flight requests, then closeAllConnections() (Node >= 18.2) and resolve REGARDLESS — teardown is bounded, never a race against the proxy's socket lifecycle. Verified live on the hub: the old runner's final stop took 90s (systemd SIGKILL); the fixed runner ran three consecutive restarts at 6s / instant / instant with the frontdoor's pooled sockets present. Regression test pins the contract: a held-open half-request socket cannot stall stop() past the grace.
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Member
Author
|
Landed on main as 0168a93. |
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.
Closes #1707.
What
AmicodeServiceServer.stop()awaited a bareserver.close(), which waits for every open keep-alive socket to end. The hub frontdoor (hub-frontdoor.py, the connection-serializing proxy) holds long-lived pooled backend sockets to the service origin plus SSE fan-outs — so stops parked the unit indeactivatinganywhere between 6 seconds and systemd's SIGKILL. Three wedged hub stops on 2026-10-04 (05:05, ~2 min to the restart job; 10:00, hand-SIGKILLed; plus the slow class throughout), each an outage window thathub-restart.sh restartblocks on.The engine kill was already bounded (
killEngine: SIGTERM → 3 s → SIGKILL); the service close was the unbounded leg.The fix (
server.ts)stop()now:close()first (no new accepts) → 2 s grace for in-flight requests →closeAllConnections()(Node ≥ 18.2; guarded for older) → resolve regardless. A stop means stop — never a race against the proxy's socket lifecycle.Verification
npx vitest run test/amicode_service_stop_bounded_1707.test.ts— 2 passed (new file: a held-open half-request socket — the parked-pooled-connection shape — cannot stallstop()past the grace, and the socket is destroyed; the no-hold case stays fast)npx vitest run test/amicode_service— 17 files / 241 tests passed (every existing harness callsstop())pnpm run typecheck— clean (schema, amico-run, extension)amicode-service-runner.mjs.bak-20261004-unbounded-stopkept); the old runner's final stop took 90 s (systemd SIGKILL); the fixed runner ran three consecutive restarts at 6 s / instant / instant with the frontdoor's pooled sockets present. Hub active,/session200 through the frontdoor.Follow-up note: this is the third fleet-runtime fix this week that lived only as a deployed copy (
rss-watchdog→ #1704, the frontdoorAPP_DISTdrift, now this) — worth folding the hub's runtime scripts (hub-frontdoor.py,amicode-server.sh) intoops/so drift can't hide them.