Hi all,
We’re seeing intermittent failures with postMessage calls from our embedded application after upgrading the Client App SDK to version 4.0.0 - we were on 3.2.0 previously. It’s not consistent, which is making it difficult to pinpoint. Sometimes it works perfectly for hours, then we get a flurry of errors.
The error in the console looks like this: Uncaught DOMException: Failed to establish a connection to the sending window.. It’s happening after the initial connection seems to be established. The documentation states the SDK “establishes a bidirectional communication channel” using postMessage, but it seems…fragile now.
We’ve checked the usual suspects - the iframe is loaded, the origin matches, the window.parent is available. It isn’t a CORS issue, we verified that. It’s only happening to users on Chrome - version 115 and above. Firefox and Safari seem unaffected, which is…strange.
The flow looks like this: Agent receives a call → Screen pop opens in embedded iframe using the Client App SDK → Our application attempts to send data back to the parent window via postMessage. We’re using the sendMessage function from the SDK, as described in the docs.
It seems like the connection is dropping unexpectedly, but there isn’t any clear indication of why. A small thing - we’ve also noticed the agent desktop seems to be slightly more sluggish overall since the upgrade. We logged a ticket internally - INC-4471.
Here’s a snippet of the code that’s failing:
function sendMessageToParent(message) {
if (window.parent && window.parent.postMessage) {
gcClientAppsFramework.sendMessage(message)
.then(response => {
console.log("Message sent successfully:", response);
})
.catch(error => {
console.error("Error sending message:", error);
});
} else {
console.warn("Parent window or postMessage not available.");
}
}
We’ve tried wrapping the sendMessage call in a try...catch block, but the exception isn’t very informative. It doesn’t give us much to go on. Change the SDK version back to 3.2.0 → problem goes away.
Here’s a quick summary of what we’ve tried:
- Upgraded Client App SDK from 3.2.0 to 4.0.0
- Verified origin matching between iframe and parent window
- Checked Chrome versions (115, 116, 117) - issue occurs on all.
- Confirmed issue is isolated to Chrome. Firefox & Safari are working as expected.
- Tested with different agents and different call types - intermittent, not tied to a specific scenario
- Wrapped
sendMessageintry...catchblock - doesn’t help with debugging. - Reviewed the documentation regarding
postMessageand the bidirectional communication channel. - Checked the developer console for any additional errors or warnings.
The documentation states that the sendMessage function “returns a Promise that resolves with a response object when the message is successfully sent”, but the promise is rejecting with this DOMException. It’s almost as if the connection is severed during the send.
Anyone else hitting something similar?