Uh oh!
There was an error while loading. Please reload this page.
fix: Vercel 404 on /api/v1/meta and /api/v1/packages — path normalisation, kernel boot resilience, broker-optional metadata - #933
Merged
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…lient metadata - api/[...path].ts: Add try-catch + path normalisation for /api prefix - api/_kernel.ts: Boot promise lock, broker reattach, non-fatal seed errors - http-dispatcher.ts: handleMetadata() no longer requires broker upfront - Add 12 new tests for Vercel delegation and broker-less metadata handling - Update CHANGELOG.md Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
CopilotAI
changed the title
[WIP] Fix 404 errors for /api/v1/meta and /api/v1/packages routesfix: Vercel 404 on /api/v1/meta and /api/v1/packages — path normalisation, kernel boot resilience, broker-optional metadataMar 18, 2026
hotlong
marked this pull request as ready for review
March 19, 2026 02:13
Uh oh!
There was an error while loading. Please reload this page.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Studio’s Vercel serverless routing failures for /api/v1/meta and /api/v1/packages by hardening the serverless catch-all, making kernel boot more resilient under cold-start concurrency, and allowing metadata handling to degrade gracefully when a broker is unavailable.
Changes:
- Add request path normalization + structured error handling in the Vercel catch-all handler.
- Add a shared boot promise and non-fatal seeding behavior to prevent cold-start races and improve resiliency.
- Make
HttpDispatcher.handleMetadata()broker-optional with ObjectQL registry fallbacks; add tests for broker-less behavior and delegation behavior in the Hono adapter.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/studio/api/[...path].ts | Wraps serverless delegation in try/catch and normalizes paths to preserve /api prefix before forwarding to the inner Hono app. |
| apps/studio/api/_kernel.ts | Adds cold-start initialization lock via shared promise; validates broker shim; makes seeding non-fatal. |
| packages/runtime/src/http-dispatcher.ts | Updates metadata handler to avoid requiring a broker and to fall back to protocol/ObjectQL registry where possible. |
| packages/runtime/src/http-dispatcher.test.ts | Adds tests validating metadata degradation behavior when the kernel has no broker. |
| packages/adapters/hono/src/hono.test.ts | Adds tests for outer→inner Hono delegation and intended path normalization/error propagation scenarios. |
| CHANGELOG.md | Documents the Vercel routing fix, kernel boot resiliency, and broker-optional metadata behavior. |
| } | ||
| // Try listing items of the given type | ||
| const items = qlService.registry.listItems?.(typeOrName, packageId); | ||
| if (items && items.length > 0) { |
Comment on lines
+604
to
+613
| it('handles path normalisation (strips prefix correctly) through delegation', async () => { | ||
| const innerApp = createHonoApp({ kernel: mockKernel, prefix: '/api/v1' }); | ||
| const outerApp = new Hono(); | ||
| outerApp.all('/*', async (c) => { | ||
| // Simulate the normalisation logic from [...path].ts | ||
| const url = new URL(c.req.url); | ||
| if (!url.pathname.startsWith('/api')) { | ||
| url.pathname = '/api' + url.pathname; | ||
| const request = new Request(url.toString(), c.req.raw); |
8 tasks
This was referenced Aug 6, 2026
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 freeto 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.
Studio's Vercel deployment returns 404 for
/api/v1/metaand/api/v1/packages. Three independent root causes: no error handling in the serverless catch-all (boot failures silently swallowed), no path normalisation (some runtimes strip/api/prefix), andhandleMetadata()unconditionally callingensureBroker()which throws 500 in lightweight setups.apps/studio/api/[...path].ts— catch-all handlergetApp()+inner.fetch()in try-catch; boot failures return structured 500 JSON instead of being swallowed/apiif the runtime stripped the function directory prefixapps/studio/api/_kernel.ts— kernel cold-startkernel.bootstrap()— reattach if lostpackages/runtime/src/http-dispatcher.ts— broker-optional metadatahandleMetadata()usesthis.kernel.broker ?? nullinstead ofthis.ensureBroker()broker.call()sites guarded withif (broker)— falls back to protocol service → ObjectQL registry → hardcoded defaultsTests
Original prompt
📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.