Skip to content

Scope pending CDP command IDs by session and reject in-flight duplicates #5085

Closed

Description

@liuxiaocs7

What happened

CdpBridge tracks outstanding commands in a Map keyed only by the client command ID. If one WebSocket connection reuses an ID before the first command completes, the later pending.set(id, ...) overwrites the first entry.

Whichever debugger call completes first then consumes the shared pending slot. The other completion is discarded, so a response can be associated with the wrong command and one request can wait until its client-side timeout.

Flattened CDP sessions have independent command-ID namespaces. Pending commands must be scoped by connection, session and ID: different sessions can concurrently use the same ID, while a duplicate still in flight within one session should be rejected without replacing the original pending command.

How to reproduce

  1. Start CdpBridge with a debugger target whose first sendCommand remains pending.
  2. Connect one WebSocket client.
  3. Send { "id": 7, "method": "Page.navigate", "sessionId": "session-a" }.
  4. Before it completes, send { "id": 7, "method": "Runtime.evaluate", "sessionId": "session-b" } on the same connection.
  5. Observe that the second command overwrites the first pending entry and both debugger calls are dispatched.
  6. Resolve the debugger calls and observe that only one completion can consume ID 7; the other response is lost.

Expected behavior: both commands above are dispatched and each session receives its own response. If step 4 instead uses session-a, the duplicate in-flight command is rejected as a protocol error without overwriting the original pending command. An ID becomes reusable within its session after success or failure, and stale results from a disconnected client must not reach a reconnecting client.

Environment

  • Maka commit: 30cf0beb0d
  • OS and version: macOS
  • Surface: Desktop
  • Node.js version: 22.19 or newer

Logs, screenshots, or additional context

Relevant code: apps/desktop/src/main/browser/cdp-bridge.ts, in onClientMessage() and takePending().

This issue was prepared and submitted by OpenAI Codex at the contributor's direction.

Activity

  1. liuxiaocs7 commented on Sep 9, 2026

    @liuxiaocs7
    MemberAuthor

    take

  2. changed the title [-]Reject duplicate in-flight CDP command IDs on one connection[/-] [+]Scope pending CDP command IDs by session and reject in-flight duplicates[/+] on Sep 13, 2026
  3. added a commit that references this issue on Sep 14, 2026
    e92e4da
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions