fix: exempt device-link pairing from timeout - #38
Merged
Morten Barklund (barklund) merged 1 commit intoSep 3, 2026
Merged
Morten Barklund (barklund) merged 1 commit into
Morten Barklund (barklund) merged 1 commit into
Conversation
Copilot started reviewing on behalf of
Morten Barklund (barklund)
August 28, 2026 11:57
View session
Contributor
There was a problem hiding this comment.
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.postMessageto accepttimeout?: number | null, wherenulldisables the timeout. - Update
CortiEmbedded.showDeviceLinkQRto passnulltimeout so pairing can remain pending indefinitely. - Add tests validating the no-timeout path in
PostMessageHandlerand verifying theshowDeviceLinkQRcall site passesnull.
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 inpendingRequests. Withtimeout: null, there is no timer to clean it up, so it can leak indefinitely. Wrap thepostMessagecall 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.
Morten Barklund (barklund)
force-pushed
the
fix-exempt-embedded-device-link-pairing-from-postmessage-dxa-3882
branch
from
August 28, 2026 12:43
91e887e to
5e4a404
Compare
Filip Weilid (filipweilid)
approved these changes
Aug 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
showDeviceLinkQRfrom the default postMessage request timeout.PostMessageHandler.postMessage(..., null)to keep a request pending indefinitely.showDeviceLinkQRcall site.Fixes DXA-3882