feat(vps): swap entry point to Effect toWebHandler (Step 2b)#145
Open
guidefari wants to merge 1 commit into
Open
feat(vps): swap entry point to Effect toWebHandler (Step 2b)#145guidefari wants to merge 1 commit into
guidefari wants to merge 1 commit into
Conversation
Step 2b of the Hono -> Effect HttpApi migration (docs/migration-effect-http-api.md). Serving topology change, zero route behavior change -- still 100% Hono fallback. - apps/vps/src/index.ts: Bun.serve's fetch now points at effectWebHandler.handler instead of app.fetch directly. Every request still reaches the same Hono app via the step 2a fallback. - apps/vps/src/app.ts: added onShutdown(dispose) so the entry point can register effectWebHandler.dispose() to run before disposeRuntime() during SIGTERM/SIGINT. Sequenced inside the existing shutdown() closure (not a second process.on listener) so it can't race the existing process.exit(0)/exit(1) calls. Background forks (reminder loop, sitemap regeneration) are unaffected -- they run inside app.ts's initializeApp(), which the entry point still imports and awaits before building the handler. Verified: full apps/vps vitest suite (140/140, 15 files) passes unchanged, including the step 1b/2a blackbox suites exercising the new effectWebHandler end to end (health, a real API route, 404, dispose() after serving real requests). Not verified here: an actual OS-level SIGTERM against a running Bun.serve process -- no local env/SST resources available in this environment to boot the server standalone. The shutdown sequencing was reasoned through manually (see comments) but a real signal to a staged/dev instance is worth a manual check before this reaches prod, per the doc's Step 2 acceptance bar.
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.
Why this exists: this is the actual cutover -- prod now serves through the Effect handler instead of Hono's Bun.serve directly. Route behavior is unchanged (still 100% Hono fallback under the hood), so this PR isolates one risk only: did the swap itself break anything (startup, shutdown, background jobs).
Stacked on #144 (merge #142 -> #143 -> #144 first).
Verification
apps/vpssuite: 140/140 passing, unchanged from before this PR.Not verified
No real SIGTERM against a booted server -- this environment can't boot vps standalone (needs SST resources). Worth a manual check on staging before prod.
The bug this caught
Naively adding a second
process.on('SIGTERM', ...)for the new handler would race the existing one, which callsprocess.exit()unconditionally. Fixed by threading the new dispose call through the existing shutdown sequence instead.Next
Step 2c: port the better-auth route onto the new router, isolated so an auth regression is diagnosable to one small diff.