2

In our crash tracking system bugsnag, I see lots of DataCloneError with the following message:

Failed to execute 'postMessage' on 'Window': 
function (e,t,n){"use strict";e.exports=n(1360)} could not be cloned.

The time when these first appeared matches upgrading to webpack 4. We're using vendor split to separate our bundle to vendor~app.js and app.js, which are added on the page in that order. The function in the error message appears in the very first part of vendor~app.js.

The error happens with multiple browsers and OS:s, but I've not been able to reproduce it myself. The site where this happens is https://wolt.com

What could cause this crash?

OlliM
  • 7,023
  • 1
  • 36
  • 47

1 Answers1

2

The error is definitely caused by passing a function to window.postMessage() (see this SO answer as to why passing a function doesn't work). The question is who's calling it? In my case, it was an extension I had running (angular augury). I found this by stubbing window.postMessage:

window._postMessage = window.postMessage
function f(...args){
  console.log({args})
  window._postMessage(...args)
  throw new Error('stack trace please')
}
window.postMessage = f

Searching your source code via the firefox debugger found several instances of window.postMessage being called, including some communication with iframes. It wasn't clear which one, if any, would regularly throw errors.

Steven Kalt
  • 1,116
  • 15
  • 25
  • Thanks Steven, this didn't quite solve the problem yet but you gave an outside confirmation that we're looking in the right direction, so I gave you the bounty. – OlliM Oct 25 '18 at 06:45