Repository navigation
Conversation
ofriw
force-pushed
the
pr/66-http-stop
branch
from
October 27, 2026 10:55
0bb30d1 to
e5ce684
Compare
This was referenced Oct 27, 2026
Closed
(cherry picked from commit 8a350d0)
…rved (cherry picked from commit 77a6fdd)
(cherry picked from commit fab1c7c)
(cherry picked from commit 1d52423)
(cherry picked from commit 557b898)
(cherry picked from commit 731c7bf)
(cherry picked from commit d907d64)
…ed URL (cherry picked from commit 6f2e52f)
Extract BaseHttpServer: drain, start/stop gate, idempotent stop and signal wiring are runtime independent. Deno and Node keep only bind and close. Also export the single 503 response used by both drain gates, so a client cannot tell which runtime rejected it, and route the post-bind server error through logging/ instead of console.error.
The gate chained every stop on an in-flight start only, so a start issued while a stop was pending could bind before that stop ran, leaving a listener the stop never closed. Queue every op behind the previous one and sanitize the tail so a failed op does not block the queue. The first op of an idle gate still runs synchronously, keeping stop()'s state change observable.
setTimeout overflows above 2^31-1 and fires in about a millisecond, so a long budget silently became an immediate force-close. Validate timeoutMs before any escalation or state change: an integer in [0, 2^31-1], else the stop promise rejects and the listener keeps serving.
A failed start left the abort controller set and the services running, so a retry returned early: the server reported success while nothing listened. Start the services into a rollback list, bind, then commit the controller and log the start metric. On failure stop what started, clear the stopping flag, log ServerStartFailed and rethrow. A failed bind now rejects instead of resolving without a listener.
ofriw
force-pushed
the
pr/66-http-stop
branch
from
October 27, 2026 12:37
e5ce684 to
11790b3
Compare
Collaborator
Author
|
Superseded by the reviewed, fully verified replacement stack: https://github.com/goatplatform/goatdb/stack/92
Each complete replacement tip passed full Deno + Node + browser suites on current Deno2.9.1 and actual floor2.3.3, with Node24.14.1 and Playwright1.64.1. Exact tip hashes, scope, dependencies, gates and breaking/data notices are in the new PR bodies. Final tip9e9a759f has 0 failures on all six full runs; the 49-source-commit content audit and independent review passed. Remote Actions status is separate from these measured local gates. Review bottom-up. This replaces the old split, not just its last diff. No PR was merged, no issue was edited, and original remote branches are retained. |
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 2 of the #66 split. Independent of the codec/storage work; base is
main.What changed
Graceful HTTP stop.
stop()now drains in-flight requests and responses before closing the listener, rejects new arrivals with a single503(Service Unavailable+connection: close), and acceptsforce/timeoutMs.timeoutMsbounds the drain only, never the final listener close, and neither force nor timeout cancels application handlers.One lifecycle owner. A new
BaseHttpServer<L>holds the drain, the start/stop gate and the signal wiring; Deno and Node keep only_bind/_close. Both runtimes therefore produce an identical rejection response. Deno's_bindracesonListenagainstserver.finished, so a busy port rejects instead of hanging. Node's_bindclears its listeners after a failed bind, so a retry starts clean.Ordering.
StartStopGateis FIFO: every start/stop runs alone, in call order, and a rejected op does not block the queue. Without this, a restart queued behind a pending stop could bind a listener that the stop never closed. The first op of an idle gate still runs synchronously, sostop()clearsport/addressbefore returning.Input validation.
validateStopTimeoutrejects a non-integer, negative, or above2^31-1budget before any state change (a 32-bit timer overflow used to fire after ~1 ms and silently force-close). The stop promise rejects and the server keeps serving.Start rollback.
Server._startstarts services into a rollback list, binds, and only then commits_abortControllerand logsServerStarted. A failure stops what started, clears_stopping, logsServerStartFailed, and rethrows. Previously a failed bind left the server looking started, so a retry returned immediately while nothing listened.ALB health checks match the parsed host and path (
http/https, any port, query ignored, case-sensitive path).Breaking
HttpServerInstance.stop()andServer.stop()returnPromise<void>and must be awaited; the promise resolves only after the port is free.Verification
deno task checkclean;deno publish --dry-runclean (the new exported class fields carry explicit types);npm run build:npm(tsup + DTS) clean, which also required dropping aDeno.ServeTcpOptionsannotation the npm Deno stub does not declare.HttpServerStopcovers: drain and 503 during drain, timeout and force interrupt a partial stream, force does not cancel handlers, idempotent stop releases the port, restart after stop, stop racing start, a pre-aborted signal leaves no listener, bind failure then same-instance retry,Server.startrollback then retry, invalid budgets leave the listener bound, the max budget still waits for an active request, gate FIFO order and rejection sanitization.Stack
Independent of #74.
pr/66-path-branding(last in the stack) expects this branch to be merged before it.Stack position
Second layer of GitHub stack #80 (
main ← #74 ← #75 ← #76 ← #77 ← #78).needing the narrow Node server type (feat(tests,cli,ci): honest skips with --fail-on-skip, npm gates, CLI fixes (3/5 of #66) #76's type-check gate) can build on it.
gh stack checkout 75.