FlowCrypt / flowcrypt-browser

FlowCrypt Browser extension for Chrome and Firefox
https://flowcrypt.com
Other
375 stars 46 forks source link

Fix "Failed to execute 'postMessage' on 'DOMWindow'" errors #5689

Closed sosnovsky closed 2 months ago

sosnovsky commented 5 months ago

Sometimes such warnings appear in console

Screenshot 2024-04-26 at 12 57 26
webmail_bundle.js:10145 Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('chrome-extension://pjohdcpiapjhagmakkjpgjmodmgfmkkd') does not match the recipient window's origin ('https://mail.google.com').
sendToChildren @ webmail_bundle.js:10145
(anonymous) @ webmail_bundle.js:10213
await in (anonymous) (async)
(anonymous) @ webmail_bundle.js:93
sendRaw @ webmail_bundle.js:10220
sendAwait @ webmail_bundle.js:10189
sendCatch @ webmail_bundle.js:10177
pgpBlockRender @ webmail_bundle.js:10419
RelayManager.flushIfReady @ webmail_bundle.js:13224
RelayManager.relay @ webmail_bundle.js:13147
RenderRelay.relay @ webmail_bundle.js:13390
RenderRelay.renderEncryptionStatus @ webmail_bundle.js:13341
MessageRenderer.decideDecryptedContentFormattingAndRender @ webmail_bundle.js:12510
MessageRenderer.renderCryptoMessage @ webmail_bundle.js:12706
await in MessageRenderer.renderCryptoMessage (async)
MessageRenderer.processEncryptedMsgAttachment @ webmail_bundle.js:12773
await in MessageRenderer.processEncryptedMsgAttachment (async)
(anonymous) @ webmail_bundle.js:12357
(anonymous) @ webmail_bundle.js:12600
RenderRelay.start @ webmail_bundle.js:13314
RelayManager.createAndStartRelay @ webmail_bundle.js:13155
MessageRenderer.relayAndStartProcessing @ webmail_bundle.js:12595
MessageRenderer.setMsgBodyAndStartProcessing @ webmail_bundle.js:12756
MessageRenderer.processAttachment @ webmail_bundle.js:12357
GmailElementReplacer.processAttachments @ webmail_bundle.js:14969
await in GmailElementReplacer.processAttachments (async)
GmailElementReplacer.processNewPgpAttachments @ webmail_bundle.js:14932
await in GmailElementReplacer.processNewPgpAttachments (async)
GmailElementReplacer.replaceAttachments @ webmail_bundle.js:14902
GmailElementReplacer.everything @ webmail_bundle.js:14624
handler @ webmail_bundle.js:14557
(anonymous) @ webmail_bundle.js:16172
(anonymous) @ webmail_bundle.js:93

We already have check for frame origin, but looks like it fails in some cases https://github.com/FlowCrypt/flowcrypt-browser/blob/b3d5aad5f4d599d1c9ed80860cd96db3c0ed5ef5/extension/js/common/browser/browser-msg.ts#L370

ioanmo226 commented 2 months ago

@sosnovsky Could you check if this issue still persists and let me know how to reproduce this issue? I tried to load gmail page for 10 times but couldn't reproduce this issue.

sosnovsky commented 2 months ago

Yeah, looks like it was fixed in some previous PR, so this issue can be closed. However, https://github.com/FlowCrypt/flowcrypt-browser/issues/5433 still happens for me