Repository navigation
fix(hub-ui): wait for trust without a deadline before the messages fetch - #495
Merged
Merged
Conversation
Background message init ran on the default 60s trust deadline. A page whose DevTools client stays unauthorized then rejected with an uncaught timeout. The initial fetch needs no deadline: it must run whenever trust arrives.
|
@0froq is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
|
👁️🗨️ Review this pull request with grouped, summarized diffs at: raw result💭 analyzed by {
"headSha": "5bb47c9accf308b8799e49c779267b13a2e6b86e",
"result": {
"overallSummary": "Fixes an uncaught rejection on auth-enforcing hosts: `useMessages`' initial feed fetch used to call `ensureTrusted()` with the default 60s deadline, which rejected with an unhandled error if the user hadn't authorized yet. The fix passes `0` to wait without a deadline, and a new test covers the gating behavior.",
"groups": [
{
"key": "fix",
"label": "Fix trust wait deadline",
"summary": "Changes `useMessages` to call `ensureTrusted(0)` instead of the default call, so the initial feed fetch waits indefinitely for trust instead of rejecting with an unhandled error after the default 60s deadline on auth-enforcing hosts.",
"category": "core",
"filePaths": [
"packages/hub-ui/src/client/state/messages.ts"
],
"critical": true,
"lineNotes": [
{
"path": "packages/hub-ui/src/client/state/messages.ts",
"side": "additions",
"line": 93,
"text": "`ensureTrusted(0)` removes the timeout for this initial wait; later trust/revocation changes still flow through the existing `devframe:messages:updated` handler, so this only affects the first fetch."
}
]
},
{
"key": "tests",
"label": "Trust wait test",
"summary": "Adds a focused test asserting the initial fetch waits for trust without calling `call` until the trust promise resolves, and that `ensureTrusted` is invoked with `0` (no deadline).",
"category": "tests",
"filePaths": [
"packages/hub-ui/src/client/state/messages.test.ts"
]
}
],
"schemaVersion": 1,
"source": "llm",
"generatedAt": "2026-11-17T07:42:41.642Z",
"model": "vercel-ai-gateway/anthropic/claude-sonnet-5",
"locale": "en"
}
} |
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.
Fixes #440
Description
useMessagesstarts its initial feed fetch withcontext.rpc.ensureTrusted(), which runs on the default 60 second trust deadline. On an auth-enforcing host where the DevTools client is never authorized, that promise rejects and nothing handles it, so the rejection surfaces as an uncaught error while the app page itself still works.The initial fetch does not need a deadline.
ensureTrusted(0)returns the pending trust promise without one, and that promise still resolves throughrequestTrustWithCode, so a user who authorizes after 60 seconds gets the feed. Later trust changes already reach the feed through the existingdevframe:messages:updatedhandler, which checksisTrusted.Limitation: the trust promise settles once, so this covers the first authorization only. A revoke and re-authorize cycle does not re-run the initial fetch.
The alternative is subscribing to
DEVFRAME_EVENTS.client.isTrustedUpdatedand refreshing when it reportstrue. That would also refetch after re-authorization and matches the shape inmessages-client.tsandcontext.ts. Three costs. Events do not replay, so a client trusted before the hub mounts needs anisTrustedcheck up front. The event firesfalseon revocation, so the handler needs a guard against refetching then.useMessagesis a module singleton with no teardown, so the listener would live as long as the page. I chose the promise because "wait for the first trust" is what it already means. Easy to switch if you prefer the event path.Test
Reference host
examples/hub-vite(embedded hub UI,@devframes/plugin-messagesmounted, interactive OTP gate on), page left unauthorized. Vite's client forwards unhandled rejections to the dev-server terminal, which is where these lines appear.Before, on
main:Both landed 60 seconds after a page load.
After the change, the same page left unauthorized for 90 seconds logs nothing, and authorizing at that point still fills the feed.
There is also a focused case in
packages/hub-ui/src/client/state/messages.test.ts. It holds the trust promise open, asserts the gate is entered without a deadline and that no list call happens yet, then resolves trust and asserts the fetch runs once. It fails on main with expected "vi.fn()" to be called with arguments: [ +0 ].