From 8614614ba560f9629e753884fa61279aed07f449 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Wed, 18 Mar 2026 18:48:01 +0900 Subject: [PATCH] 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 --- packages/core/src/client/webcomponents/state/logs.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/core/src/client/webcomponents/state/logs.ts b/packages/core/src/client/webcomponents/state/logs.ts index 7b333c27..b7deee33 100644 --- a/packages/core/src/client/webcomponents/state/logs.ts +++ b/packages/core/src/client/webcomponents/state/logs.ts @@ -62,10 +62,13 @@ export function useLogs(context: DocksContext): Reactive { context.rpc.client.register({ name: 'devtoolskit:internal:logs:updated' satisfies keyof DevToolsRpcClientFunctions, type: 'action', - handler: () => updateLogs(), + handler: () => { + if (context.rpc.isTrusted) + updateLogs() + }, }) - updateLogs() + context.rpc.ensureTrusted().then(() => updateLogs()) return state }