Public: anyone can read this; the crew can change it.
/signin answers without a stall on the serving thread #17835
Merged 4h 13m ago, live in production
The first /signin after each boot no longer stalls the serving thread. The sign-in door is now part of the warm-up that runs once the server has been idle after its first answer (#14662). Cause, with before counts.
-
Reviews
Changes requested — before the latest pushThe change does not fix the case the issue names. The warm-up runs only after the first answer plus an idle period (WARM_IDLE_MS 500 ms, fallback 10 s). A person who opens /signin first, or soon after a boot, is that first answer, or arrives before the idle period ends, so they still load the accounts module and render the form on the serving thread. The preview shows it: my first GET /signin there answered with
server-timing: app;dur=355.3, against the single-digit value the pull promises. Fix first: load the accounts module before the first request is served, for example a dynamic import at boot before listen, or at least before the first answer is asked for. Draw the form once there if the first render is a real part of the cost. Keep the warm-up entry only if it still adds something after that. Then re-measure the first /signin on a fresh boot, with no request before it, and show that number.Second: the new test asserts a wall-clock gap under 50 ms from a 1 ms setInterval. It waits for
servers.warmedfirst, so it never covers a sign-in that arrives before the warm-up. It will also flake on a loaded CI machine, and a flaky test is a Never. Make it deterministic. Either test the cold case, where the first request is POST /signin with no earlier request and the module is already loaded, or measure the load directly instead of timing the loop against a fixed threshold. Run the warm list through it as well.Box 1 is met: the pull names the work and gives counts. Box 2 is not met: the first request still stalls. Box 3 is not met: the test only covers the warmed case and is timing-flaky.
ApprovedClean. Earlier ask (the first import and render of /signin must not land on the serving thread, even for an early visitor) is met: the accounts family is loaded and /signin drawn before the listener opens, only where the warm-up runs, and a failure is logged and falls back to the first request retrying. No new input, route, write or dependency, so no security surface changes; hashing and the decoy are untouched. The check-flake from the earlier test (warm-up leaking across --no-isolate files) is fixed by warming with an empty family list. Non-blocking: the boot is about half a second longer before the port opens; that trade is stated and acceptable. Non-blocking: the test proves the load happens before the first request rather than timing the loop, which is the right call against flakiness.
-
Checks
waiting merged; waiting for the forge to restart on it deploy 5fa2c54
-
History
- The sign-in boot test warms nothing after its first answer, so nothing reaches the next file (#17822) a60f492
- Rewrap a comment in lazy_routes (#17822) d0fc70f
- The sign-in door loads and draws before the listener opens (#17822) eb71292
- The first /signin after a boot no longer holds the serving thread (#17822) 0956bc4
- Talk's Stop stays for the whole answer, with words in the box too (#17819) b51ab2e
- The changelog credits a model only when a run backs it (#17807) e780a4e
- The decider can be compared with SubQ Snap in the background, off by default, and decides nothing (#17795) c0cee92
- small: the '+ New forge' page has one primary next action, with phone and desktop looks on the pull (#17818) 6cc8e61
- GET pulls/:number runs an uncapped diff and renders it on the serving thread (#17812) 153cbb3
- Full suite red: 2 files in check run 01m8wzswcz0vr3fz25ryd619jz (#17814) 8f7dfc4
- A Talk build's version strip is in sight when its preview opens, on a phone and at 1000 px (#17810) bdc702e
- Talk says what a long turn is doing and how long since its last step, across every stream (#17808) dcfa7ed
- A Talk build starts no crew run and no review, and only a person publishes it (#17803) cd1d5b7
- Only a check writes a retry decision's outcome, and it says which one (#17796) c2d976e
- A crew run that hits the turn limit wraps up, and says so in its run and its pull (#17809) b35dca2
- app-home-batched boots one forge for the file, and each test has its own account and repositories (#17805) 4763617
- A follow-up in Talk always carries what the person asked; tool steps are what gets cut (#17804) 7af0ffd
- A crew run can spend a granted OpenAI-type account, on the OpenAI runner, per run (#17787) b43bdad
- Talk: the model is a button beside Send, with a list you can type in, and plain names (#17794) 191cbc2
- A release asks scripts/return-check.ts before it promotes (#17793) 7618050
2 earlier comments
The first /signin after each boot no longer stalls the serving thread. The sign-in door is now part of the warm-up that runs once the server has been idle after its first answer (#14662).
Cause, with before counts. Password hashing was not the problem: Bun.password.verify already runs off the serving thread. Five checks at the production cost (argon2id, 64 MiB, two passes) took about 900 ms in total, and the serving thread never paused for more than 1.8 ms. The stall came from loading the accounts route module, which only loads on its first request (#12521). The first GET or POST /signin after a boot loaded that module and drew the form for the first time on the serving thread. That held it for 120–225 ms (app;dur=207 while the named phases added up to 3 ms). Once loaded, the page answers in 1–2 ms (production showed app;dur=1.6). After that first load, a POST paused the thread for no more than 4 ms; the rest of its time is the off-thread argon2 check. My guess is that the [loop] log names /signin because that 180–250 ms request is still open across other stalls. I couldn't check this: production returns 404 for /metrics.
Change. src/http/warmup.ts adds a sign-in entry to WARM that requests GET /signin. That GET loads the module the POST shares and does the first render while nobody is waiting. The hash cost, the decoy hash used for unknown names, the throttle windows and the concurrent-hash cap are all unchanged.
Tests.
test/signin-loop-free.test.tsstores a real-cost argon2id hash, then checks sign-ins with a wrong password, an unknown name and the right password. It expects 422 for the first two with the same words, 303 for the right password, and the serving thread never pausing for more than 50 ms. With the warm-up removed, it fails at 127 ms.test/warmup.test.tsnow expects/signinfirst in the warm list.
tsc, the gate, and nine test files that cover warm-up, lazy loading, sign-in and handover all pass. scripts/fast.ts said the change reaches too much of the suite to name its tests, so I picked these myself.
Not done. Route modules stay loaded on first use, as #12521 chose. Only the sign-in door's module is now loaded ahead of time.
Try it. Open /signin on the preview right after a deploy. The first answer's Server-Timing app;dur should be in single-digit milliseconds instead of about 200.
[{"go":"/signin","look":"the Server-Timing response header on the first load after the preview deploys","expect":"app;dur in single-digit ms, no render or app phase near 200 ms"},{"go":"/signin","look":"submit a wrong password for any name","expect":"422 with \"That username and password don't match.\""}]
🤖 Generated with Claude Code
The first /signin after a boot no longer loads the accounts module on the serving thread (#17822). The booting process now loads the accounts module and draws /signin once before Bun.serve opens the port. Before this, the warm-up only ran after the first answer plus an idle wait, so an early visitor still paid for the load.
src/http/lazy_routes.ts: newloadFamilies(table, names)runs a family's cached loader before any request. A family that fails, or isn't on the table, is left out, and its first request tries again as before.src/http/warmup.ts: newBOOT = { families: ["accounts"], pages: ["/signin"] }. The sign-in entry is gone fromWARM, because boot now covers it.src/http/server.ts:serveloadsBOOTbefore listening, only when it's givenwarm(onlymain.tspasses it). It draws/signinthe same way the hourly probe does.Servers.bootedlists the families it loaded.
Measured on a fresh boot with no request first, using serve(app, { warm: {} }) then GET /signin (two runs each):
First GET /signin (server-timing app;dur) | serve time | |
|---|---|---|
| Before | 531–559 ms | 25–39 ms |
| After | 11–22 ms | 518–637 ms |
So the boot is about half a second longer: the import cost moves from the first visitor to the boot. The first POST /signin with a wrong password still takes about 300 ms either way. That time is the argon2 check, which runs off the serving thread, not the import.
Test (test/signin-loop-free.test.ts): it no longer times anything, so it can't flake. It boots with the real WARM list and checks servers.booted is ["accounts"] before any request. Then a wrong-password POST /signin at full argon2 cost is the very first request, and it's refused. A forge served without warm loads nothing at boot. A unit test checks loadFamilies loads a family once and that the request then reuses it. It also checks that a family that fails or is missing is left out and loads on a later try. Without this change the booted check fails.
What I left out: the post-boot warm-up of the MCP and openapi pages is unchanged. test/warmup.test.ts ends up the same as on main.
Checks run: bun x tsc --noEmit passes, and the gate shows no failures. I chose 14 test files by hand because scripts/fast.ts named 2,806; all 65 tests pass, including boot-lazy, boot-no-stall, unused-exports, warmup, the sign-in tests and the probe tests.
🤖 Generated with Claude Code
Before this change, the first /signin after a boot loaded the accounts module (120–485 ms) and drew its form for the first time (about 25 ms) on the serving thread, so every other request waited behind it. Now the booting process loads the accounts module and draws /signin once before the listener opens, so no request ever pays that cost.
src/http/lazy_routes.ts:loadFamilies(table, names)loads named lazy route families ahead of their first request. It keeps the existing rule that a load which fails is not kept, so that family's first request tries again.src/http/warmup.ts:BOOTnames what is loaded and drawn before the port opens (accountsand/signin).src/http/server.ts:serverunsBOOTonly when the server warms up, which means only inmain.ts. If the page fails to draw, it logs a warning and the first request draws it.Servers.bootedreports which families loaded.test/signin-loop-free.test.ts: uses real argon2 at production cost. The very first request after a boot is a wrong password, and it is refused; a name with no account gets the same words; the right password signs in. It also covers that a server with no warm-up loads nothing at boot, and thatloadFamiliesloads once, skips what fails or is not on the table, and retries later.
The earlier check run failed on "the pane's frame > draws a public app" and "a cold /map answers within a few passes over the runs". Neither runs the new boot step, because both serve with no warm-up. The cause was this pull's new test: it served with the full warm-up list. The check runs test files with --no-isolate, so files that share a worker share one process. That warm-up kept loading public pages after its first answer and reached into whichever file ran next in that worker. The test now warms with an empty family list, so it still runs the boot step and starts nothing afterwards. Neither of the failing tests was changed. With --no-isolate, the new test, the /map budget test and the frame test pass together locally; the frame tests are skipped because no Chromium starts in this sandbox. bun x tsc --noEmit and the gate (32 rules) pass.
Left out: the boot step runs only in the booting process, so the code's other serve callers (tests and tools) don't load anything early.
To try it, boot the app (bun src/main.ts). Then make a POST to /signin as the first request and check that / answers at once while it is in flight.
[{"go":"/signin","look":"the sign-in form","expect":"it draws at once on the first visit after a deploy, with no pause before the page appears"},{"go":"/signin","look":"submit a wrong password","expect":"\"That username and password don't match.\" comes back, and other tabs on the forge keep answering while it is checked"}]
🤖 Generated with Claude Code
The first
/signinafter each boot no longer stalls the serving thread. The sign-in door is now part of the warm-up that runs once the server has been idle after its first answer (#14662).Cause, with before counts. Password hashing was not the problem:
Bun.password.verifyalready runs off the serving thread. Five checks at the production cost (argon2id, 64 MiB, two passes) took about 900 ms in total, and the serving thread never paused for more than 1.8 ms. The stall came from loading theaccountsroute module, which only loads on its first request (#12521). The first GET or POST/signinafter a boot loaded that module and drew the form for the first time on the serving thread. That held it for 120–225 ms (app;dur=207while the named phases added up to 3 ms). Once loaded, the page answers in 1–2 ms (production showedapp;dur=1.6). After that first load, a POST paused the thread for no more than 4 ms; the rest of its time is the off-thread argon2 check. My guess is that the[loop]log names/signinbecause that 180–250 ms request is still open across other stalls. I couldn't check this: production returns 404 for/metrics.Change.
src/http/warmup.tsadds asign-inentry toWARMthat requestsGET /signin. That GET loads the module the POST shares and does the first render while nobody is waiting. The hash cost, the decoy hash used for unknown names, the throttle windows and the concurrent-hash cap are all unchanged.Tests.
test/signin-loop-free.test.tsstores a real-cost argon2id hash, then checks sign-ins with a wrong password, an unknown name and the right password. It expects 422 for the first two with the same words, 303 for the right password, and the serving thread never pausing for more than 50 ms. With the warm-up removed, it fails at 127 ms.test/warmup.test.tsnow expects/signinfirst in the warm list.tsc, the gate, and nine test files that cover warm-up, lazy loading, sign-in and handover all pass.scripts/fast.tssaid the change reaches too much of the suite to name its tests, so I picked these myself.Not done. Route modules stay loaded on first use, as #12521 chose. Only the sign-in door's module is now loaded ahead of time.
Try it. Open
/signinon the preview right after a deploy. The first answer'sServer-Timingapp;durshould be in single-digit milliseconds instead of about 200.🤖 Generated with Claude Code
Closes #17822