Returning a moment result object in transformer produces Failed to execute 'postMessage' on 'Window error

I noticed that if I return the result of a moment response as part of an transformer (e.g. return { date: moment() }), I get this error:

message:"Failed to execute 'postMessage' on 'Window': function(e){var a=e%10;return e+(1===k(e%100/10)?"th":1===a?"st":2===a?"nd":3===a?"rd":"th")} could not be cloned."

Just return moment() works (preview shows a string, although the response is typeof object), as does return { date: new Date() }.

There's some discussions here and here by @jssln and @brettski referencing 'Failed to execute 'postMessage' on 'Window'' errors, and perhaps this response, gets to the root of it.

The workaround seems to be to just return { date: new Date(moment()) }, which is probably what I wanted in the first place, since moment doesn't return a Date object anyway.

Still a weird error to get. Thought I'd post it in case someone else runs into it.


Thank you for such an incredibly thorough report. I've run into this many times, and I really appreciate you sharing the workaround for the other users that will inevitably run into this as well.

I've passed this to eng to get their eyes on this as well.


Hi @joostschuur,

Returning return { date: new Date(moment()) } is the same as saying return { date: new Date() }, which creates a new Date object as of the time it was called.

In both cases a stringified version of the date (e.g. 2022-12-05T15:29:36.243Z) will be sent along, returned.

Understood that this is the same thing. The specific bug only ocurrs when I send the result of a moment call back as part of an object (return { date: moment() }). The other examples I gave was just me showing what didn't trigger the error.

As it turns out, I didn't actually want the unprocessed result from moment either, so this is more of a general bug report that depending on the returned result, you might get a reallty confusing error message :slight_smile:

Yes, returning a moment object isn't very helpful in this case. Glad you have it all straightened out.