Skip to content

fix: defer logs RPC call until client is authorized#227

Merged
antfu merged 1 commit intomainfrom
antfu/skip-rpc-unauthorized
Mar 18, 2026
Merged

fix: defer logs RPC call until client is authorized#227
antfu merged 1 commit intomainfrom
antfu/skip-rpc-unauthorized

Conversation

@antfu
Copy link
Member

@antfu antfu commented Mar 18, 2026

Description

Prevents unauthorized RPC errors when connecting to DevTools. The client trust request fires asynchronously in the background, but useLogs() was calling devtoolskit:internal:logs:list synchronously on component mount, before trust was established. This caused "Unauthorized access" errors.

Now guards the initial logs query with ensureTrusted(), matching the pattern used by shared state. Also guards the server-push handler to prevent logs:updated events from triggering unauthorized calls.

Changes

  • Defer initial updateLogs() call until ensureTrusted() resolves
  • Guard the logs:updated RPC handler to skip updates while untrusted

🤖 Generated with Claude Code

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>
@antfu antfu merged commit fcedc43 into main Mar 18, 2026
2 checks passed
@antfu antfu deleted the antfu/skip-rpc-unauthorized branch March 18, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant