ReviewOS

home-lang/home

fix(runtime): port inspector HTTP server agent events

#760
Closed glennmichael123 opened this 10 days ago ·
10 days ago

Parent: #66

The inspector's HTTP server domain never receives events. In packages/runtime/src/jsc/HTTPServerAgent.zig, notifyServerStarted, notifyServerStopped and notifyServerRoutesUpdated are _ = this; _ = instance; no-ops (gutted in 6c6bb0f, "chore: wip"). Bun__HTTPServerAgent__setEnabled is real, so the agent is enabled but silent. Separately, Bun__InspectorBunFrontendDevServerAgent__setEnabled is a noop entry in packages/runtime/src/native_stubs.zig:76.

Port the bodies from ~/Code/bun/src/jsc/HTTPServerAgent.zig (L14-92) and the setEnabled export from ~/Code/bun/src/runtime/server/InspectorBunFrontendDevServerAgent.zig (L107-111), removing the noop stub so the symbols do not collide.

Verification: unchanged test/cli/inspect files vs pinned Bun 4982b91e37.

10 days ago

Partly fixed on origin/main in 2d7833ecf: the three HTTPServerAgent.notify* bodies are restored from upstream, and InspectorBunFrontendDevServerAgent exports the real Bun__InspectorBunFrontendDevServerAgent__setEnabled (its native_stubs.zig no-op is gone). Keeping this issue open — the HTTP-server half does not deliver yet.

Unchanged test/cli/inspect, same JSC debug build, control = the same tree with the runtime changes stashed:

passfail
Home, unchanged parent18
Home, 2d7833ecf63
pinned Bun 4982b91e3781 (dep)

Five BunFrontendDevServer cases flipped to passing: clientConnected/clientDisconnected, bundleStart/bundleComplete, bundleFailed, clientNavigated, consoleLog.

Still failing, all three reproducing on the unchanged parent:

  1. HTTPServer … should receive serverRoutesUpdated event with route information times out at 5,001 ms. The agent bodies are not the blocker: the test spawns the server with --inspect-wait=unix:<relative>.sock and connects to it, and on Home the spawned process prints the Bun Inspector banner and Listening on unix:… but the socket is not connectable — its own log shows [socket] onConnectError (2) (ENOENT) — so no session ever attaches and neither HTTPServer.listen nor serverRoutesUpdated can arrive. Pinned Bun attaches and passes. This is an inspector-transport gap for unix-socket URLs, to be tracked on its own.
  2. sends exactly one clientNavigated event per SetUrl message — the event now arrives but not exactly once; this is a DevServer-side duplicate, unchanged by this commit.
  3. inspect.test.ts cannot load: Cannot find package 'strip-ansi', which pinned Bun reproduces — an environment gap with no parity credit either way.
10 days ago

Completed on origin/main in c6ab9aeeb, authored and committed as Chris Breuer without coauthors.

The remaining runtime defects were both in the dev-server reload lifecycle:

  • Bun.serve() only recognized HTTPServer entries in the hot map. Development servers use DebugHTTPServer/DebugHTTPSServer, so reload constructed a second server with the same ID and panicked. Home now reuses all four HTTP/HTTPS server variants, matching pinned Bun.
  • the Zig HMR socket emitted clientNavigated once before route lookup and again after a matched lookup. The second notification/helper is removed, matching pinned Bun's current Rust HMR implementation while retaining one event for matched and unmatched routes.

The copied Bun test topology now includes the pinned Bake data-view/error decoder sources and base TypeScript config required to load the unchanged inspector file.

Verification on the required native ReleaseFast build:

  • build: 50/50 steps
  • unchanged HTTPServerAgent.test.ts: 1 pass / 0 fail, including initial routes, hot reload, updated routes and close
  • unchanged BunFrontendDevServer.test.ts: 6 pass / 0 fail / 2 upstream TODO, including the exact one-event regression
  • complete unchanged test/cli/inspect: 35 pass / 0 fail / 4 upstream TODO / 122 assertions / 7 snapshots

No test fixture, assertion, deadline, skip, TODO or expected outcome was changed. Closing this issue.

10 days ago

Complete on origin/main as of c6ab9aeeb, which closed the two cases 2d7833ecf left open. Verified on a fresh JSC debug build of that tree: unchanged test/cli/inspect is 8 pass / 2 todo / 1 fail, matching pinned Bun 4982b91e37 exactly, with the only failure being inspect.test.ts unable to load strip-ansi (absent from ~/Code/bun/node_modules; pinned Bun reproduces it).

Trajectory on the unchanged directory: 1 pass / 8 fail before the agent bodies were restored, 6 / 3 after, 8 / 1 now.

Also correcting my earlier comment here: I attributed the HTTPServer timeout to a unix-socket transport gap and filed #766 for it. That was wrong — Home matches pinned Bun on every unix-socket case I could isolate, including a verbatim replication of the test's beforeAll. The measurements are on #766.

Sign in to comment on this issue.