fix: defer AuthPlugin route registration to kernel:ready hook#884
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…rder HonoServerPlugin in CLI AuthPlugin now registers HTTP routes via a kernel:ready hook instead of directly in start(). This makes it resilient to plugin loading order — the http-server service is guaranteed to be available after all plugins have completed their init/start phases. The CLI serve command now registers HonoServerPlugin before config plugins (with duplicate detection) so the http-server service is available earlier in the lifecycle for any plugin that needs it. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Address code review feedback by extracting duplicate hook capture logic into a shared createHookCapture() utility at the test suite level. Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix auth service routes not accessible due to plugin order
fix: defer AuthPlugin route registration to kernel:ready hook
Mar 9, 2026
hotlong
marked this pull request as ready for review
March 9, 2026 06:17
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where AuthPlugin HTTP routes were silently failing (returning 404) because AuthPlugin.start() tried to look up the http-server service before HonoServerPlugin had been initialized, due to CLI registering config plugins before the Hono server plugin.
Changes:
auth-plugin.ts: Moves HTTP route registration fromstart()into a deferredkernel:readyhook, ensuring all plugins have completed their init/start phases before route registration, making the plugin resilient to any plugin loading order.serve.ts: RegistersHonoServerPluginbefore config plugins in the CLIservecommand (with duplicate detection viap.name === 'com.objectstack.server.hono'), and consolidates the comment for the remaining REST API and Dispatcher plugin registrations.auth-plugin.test.ts: Adds acreateHookCapture()helper to capture and simulatekernel:readytriggers in tests, adds one new test, and updates all Start Phase tests to reflect the new deferred registration behavior.ROADMAP.md: Documents the bug fix in the migration notes.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
packages/plugins/plugin-auth/src/auth-plugin.ts |
Defers auth route registration from start() to a kernel:ready hook, making it order-independent |
packages/plugins/plugin-auth/src/auth-plugin.test.ts |
Adds createHookCapture() utility; updates tests to trigger kernel:ready before asserting route registration |
packages/cli/src/commands/serve.ts |
Moves HonoServerPlugin registration before config plugins loop; adds duplicate detection |
ROADMAP.md |
Adds a migration note documenting the bug fix |
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.
AuthPlugin.start()synchronously looks uphttp-serverservice, but CLI registersHonoServerPluginafter config plugins — so the service doesn't exist yet and auth routes silently fail with 404.Changes
auth-plugin.ts: Move route registration into akernel:readyhook (same patternHonoServerPluginalready uses forserver.listen). All plugins are guaranteed initialized+started before the hook fires, eliminating order sensitivity.serve.ts: RegisterHonoServerPluginbefore config plugins (belt-and-suspenders). Added duplicate detection (p.name === 'com.objectstack.server.hono') to skip if config already includes one.auth-plugin.test.ts: Tests now capture hook registrations via sharedcreateHookCapture()helper and triggerkernel:readyto validate route setup. +1 new test, 32/32 pass.Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.