Skip to content

Commit 8614614

Browse files
antfuclaude
andcommitted
fix: defer logs RPC call until client is authorized
Skip querying logs:list before client trust is established. The trust request (requestTrust) is async and completes in the background. Meanwhile, useLogs() fires synchronously on component mount, causing an unauthorized RPC error. Guard the initial updateLogs() call with ensureTrusted(), matching the pattern used by shared state. Also guard the logs:updated handler to prevent server pushes from triggering queries while untrusted. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent dc9218c commit 8614614

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • packages/core/src/client/webcomponents/state

packages/core/src/client/webcomponents/state/logs.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,13 @@ export function useLogs(context: DocksContext): Reactive<LogsState> {
6262
context.rpc.client.register({
6363
name: 'devtoolskit:internal:logs:updated' satisfies keyof DevToolsRpcClientFunctions,
6464
type: 'action',
65-
handler: () => updateLogs(),
65+
handler: () => {
66+
if (context.rpc.isTrusted)
67+
updateLogs()
68+
},
6669
})
6770

68-
updateLogs()
71+
context.rpc.ensureTrusted().then(() => updateLogs())
6972
return state
7073
}
7174

0 commit comments

Comments
 (0)