Skip to content

fix: exempt device-link pairing from timeout - #38

Merged
Morten Barklund (barklund) merged 1 commit into
mainfrom
fix-exempt-embedded-device-link-pairing-from-postmessage-dxa-3882
Sep 3, 2026
Merged

Morten Barklund (barklund) merged 1 commit into
mainfrom
fix-exempt-embedded-device-link-pairing-from-postmessage-dxa-3882

Conversation

@barklund

Copy link
Copy Markdown
Member

Summary

  • Exempt showDeviceLinkQR from the default postMessage request timeout.
  • Allow PostMessageHandler.postMessage(..., null) to keep a request pending indefinitely.
  • Add regression coverage for the no-timeout path and the showDeviceLinkQR call site.

Fixes DXA-3882

Copilot AI lite review requested due to automatic review settings August 28, 2026 11:56
@linear-code

linear-code Bot commented Aug 28, 2026

Copy link
Copy Markdown

DXA-3882

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the embedded iframe messaging layer to support disabling request timeouts (via null) and uses that capability to exempt the device-link pairing flow (showDeviceLinkQR) from the default postMessage timeout, with regression tests covering both the handler behavior and the call site.

Changes:

  • Extend PostMessageHandler.postMessage to accept timeout?: number | null, where null disables the timeout.
  • Update CortiEmbedded.showDeviceLinkQR to pass null timeout so pairing can remain pending indefinitely.
  • Add tests validating the no-timeout path in PostMessageHandler and verifying the showDeviceLinkQR call site passes null.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/utils/PostMessageHandler.ts Adds support for null timeout (no timer) and adjusts timeout cleanup logic.
src/CortiEmbedded.ts Exempts showDeviceLinkQR from default timeout by calling postMessage(..., null).
test/post-message-handler.test.ts Adds regression test ensuring requests don’t time out when timeout is disabled.
test/corti-embedded.test.ts Adds regression test ensuring showDeviceLinkQR passes null timeout to the handler.
Suppressed comments (1)

src/utils/PostMessageHandler.ts:310

  • If contentWindow.postMessage(...) throws (e.g., DataCloneError), the Promise rejects but the request remains in pendingRequests. With timeout: null, there is no timer to clean it up, so it can leak indefinitely. Wrap the postMessage call in a try/catch and on error delete the pending request and clear any timeout before rejecting.
        if (timeoutId !== null) clearTimeout(timeoutId);
        reject(new Error("Cannot determine trusted origin for postMessage"));
        return;
      }
      contentWindow.postMessage(fullMessage, targetOrigin);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/utils/PostMessageHandler.ts
@barklund
Morten Barklund (barklund) force-pushed the fix-exempt-embedded-device-link-pairing-from-postmessage-dxa-3882 branch from 91e887e to 5e4a404 Compare August 28, 2026 12:43
@barklund
Morten Barklund (barklund) merged commit a9f478b into main Sep 3, 2026
5 checks passed
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.

3 participants