Repository navigation
fix(server): follow-ups from the review of the server/index.ts split - #1393
Conversation
#1384 moved createCore, and with it the PTY sidecar's Node probe, after the first tailnet identity read. The probe is a spawnSync with a 3 s timeout; while it holds the thread, the identity read's own 2.5 s limit keeps running, and a read cut short leaves the owner unknown for five minutes. Start the read after createCore, as it ran after the probe before #1384. Co-Authored-By: Claude Opus 5.5 <[email protected]>
server/core imported paneContext from server/pane-routes.ts, an HTTP route file. It now lives in server/pane-context.ts, which the routes and the core both import. Co-Authored-By: Claude Opus 5.5 <[email protected]>
createCore spread the terminal, input and pending frame objects into the record the socket looks frames up in. Anything else on one of them would have become a frame type a client can send, and a type defined twice would have replaced a handler without a word. Each type is now named with its handler, so neither can happen: an extra name, a missing one or one written twice fails the build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ownership.test.ts matched imports and exports with regular expressions, which missed require(), a template-literal import() and a last export without a semicolon. It now parses each file with TypeScript's parser (typescript-api), resolves the tsconfig path aliases, and covers both checks with fixtures that must fail and fixtures that must pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Summary
Merge Risk: ⚪ Minimal · up to
|
This answers one open question from the `server/index.ts` split: what keeps `createServer`'s start-up order from breaking. Nothing pinned it, and #1384 broke it. That PR started the first tailnet identity read before the PTY sidecar's Node probe, and #1393 moved the read back. This PR pins the order that broke. ## The order and why it matters - The Node probe (`sidecarAvailable` → `isRealNode`) is a `Bun.spawnSync` with a 3 s timeout. - The identity read times itself (2.5 s) from the moment it starts. - If the read starts first, the probe's wait counts against the read's limit. - A read cut short leaves the owner unknown for five minutes. With no token and nothing paired, another tailnet user then gets `open` access. ## What changes - **`server/startup-order.test.ts` (new).** The test runs `createServer` with a probe that records itself and a `TailnetIdentitySource` whose status reader records itself. It waits for the read, then expects the probe first. I moved `identityOf(false, null)` back before `createCore`, as it was in #1384, and the test failed with `["identity read", "probe"]`. With the code as it is, the test passes. - **The `sidecar` option** also takes a function, a probe to run in place of the real one, the way `terminalAttach` already takes a value or a function. A boolean works exactly as before, so nothing else changes. - **No changelog fragment.** The change is a test seam and a test, and no user sees it. The handoff's other order question was about the collector's first frame carrying live OmO and Claude status. It is left to `createCore`'s comment: nothing has broken there, and it would need a much heavier test. ## Verification - `bun run typecheck` is clean. The conventions tests pass. - Pins were every contract test that passes `sidecar` (`conversation-push`, `api`, `usage-login`) plus `device-access` (the tailnet access paths). Each ran with `--rerun-each 3`, on `main` first and then on this branch: 495 pass, 0 fail on `main`, 495 pass, 0 fail on the branch. - `bun run check fast`: 4,502 pass, 0 fail, 8 skip. `bun run check integration`: 589 pass, 0 fail, 1 skip. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <[email protected]>
Follow-ups from the merge pass's review of the
server/index.tssplit (#1365–#1384), as one PR. There is one commit per item.1. Start the tailnet identity read after the Node probe again (fix)
#1384 moved
createCoreafter the HTTP services, and with it the PTY sidecar's Node probe. The first tailnet identity read (identityOf(false, null)) therefore started before the probe instead of after it.sidecarAvailable→isRealNode) is aBun.spawnSyncwith a 3 s timeout.openaccess.Codex reproduced this with a stalled probe and a large status reply. The merge pass could not reproduce it on Linux with Bun 1.4.3, and macOS and Windows were not tried.
The read now starts right after
createCore, so it runs after the probe as it did before #1384. Nothing thatcreateCorestarts reads the tailnet identity. #1384 claimed the two groups were independent, and that was wrong about time: a thread blocked by one counts against the other's timeout.#1384 is unreleased, so no released behaviour changes and this PR has no changelog fragment.
2. Move
paneContextout of the pane routesserver/core/input.tsandserver/core/composer.tsimportedpaneContextfromserver/pane-routes.ts, an HTTP route file. It now lives inserver/pane-context.ts, and the routes,workspace-routes.ts,index.tsand the core all import it from there. The body is unchanged.3. Name each frame type in the socket's handler record
createCoreused to spreadterminalFrames,inputFramesandpendingFramesinto the record that the socket looks frames up in. That had two weaknesses:Each frame type is now named with its handler in an object literal passed straight to
createSocket. I checked by editing the record and runningtsc:ping, fails with TS2353.The handlers are the same functions as before, so dispatch does not change. They are plain functions that do not use
this.4. Read the core's boundary with the TypeScript parser
ownership.test.tsused regular expressions. They missedrequire(), a template-literalimport()and a last export with no semicolon. Both checks now parse each file with TypeScript's parser (typescript-api, already in the repo forscripts/build-xterm.ts).Import check. It reads:
import x = require();import(),require(),require.resolve()andmock.module()with a string or template literal;import("…")types.It resolves relative names and tsconfig's
@shared/*alias. A template literal with substitutions counts when its fixed start already points insideserver/core/.Export check. It reads every statement of
server/core/index.ts.export *,export * as, default exports and exported declarations all count as names.Fixtures. 17 sources must be reported, including the three forms named in the review and
@shared/../server/core/…. 9 sources must pass, among them the index in its four spellings, a mere string or comment and a template import outside the core. Every export form has its own fixture.The real scan covers
server,src,shared,scripts,site,telemetryandapp, and still asserts that it includesserver/index.ts.Verification
bun run typecheck: clean.server/conventions.test.ts,scripts/conventions.test.tsandserver/core/: 29 pass, 0 fail.server/*.contract.test.ts(39 files) with--rerun-each 3, run onmainfirst and then on this branch: 1,602 pass, 3 skip, 0 fail onmain, 1,602 pass, 3 skip, 0 fail on the branch.bun run check fast: 4,501 pass, 0 fail, 8 skip.bun run check integration: 589 pass, 0 fail, 1 skip.Bun.sleepmoved, andscripts/fixed-sleeps.jsonis unchanged.🤖 Generated with Claude Code