Skip to content

Conversation

@ffmcgee725
Copy link
Member

@ffmcgee725 ffmcgee725 commented Nov 6, 2025

Explanation

Previously, the transport initialized requestId to 1 and incremented it for each request. This caused issues when:

  • A user disconnected and reconnected the transport
  • Pending requests from the previous connection were still in flight
  • New requests after reconnection would reuse the same IDs (starting from 1 again)
  • This led to ID collisions where responses could be matched to the wrong request

This PR updates windowPostMessageTransport to use getUniqueId() util function as the initial request ID instead of starting from 1. This change is necessary to prevent said request ID conflicts across disconnect/reconnect cycles, particularly on Firefox.
We also update externallyConnectableTransport for consistency.


Note

Randomizes initial request IDs in windowPostMessageTransport and externallyConnectableTransport using getUniqueId, updating tests and changelog accordingly.

  • Transports:
    • Initialize requestId with getUniqueId() in src/transports/windowPostMessageTransport.ts and src/transports/externallyConnectableTransport.ts to avoid ID collisions across reconnects.
  • Utils:
    • Add getUniqueId() in src/helpers/utils.ts for generating rollover-safe unique IDs.
  • Tests:
    • Update tests to mock getUniqueId() and assert dynamic IDs in windowPostMessageTransport.test.ts and externallyConnectableTransport.test.ts.
  • Docs/Changelog:
    • Add Unreleased entry describing the fix in CHANGELOG.md.

Written by Cursor Bugbot for commit 31accf1. This will update automatically on new commits. Configure here.

@ffmcgee725 ffmcgee725 requested a review from a team as a code owner November 6, 2025 13:56
@ffmcgee725 ffmcgee725 changed the title fix: use timestamp based request id in windowPostMessageTransport fix: use randomly generated request id in windowPostMessageTransport and externallyConnectableTransport Nov 11, 2025
@ffmcgee725 ffmcgee725 merged commit ce8c429 into main Nov 11, 2025
22 checks passed
@ffmcgee725 ffmcgee725 deleted the jc/fix-window-post-message-transport-request-id branch November 11, 2025 16:09
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.

4 participants