From 1e3078d6c40381f30768d982b681d0851709b86c Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Sat, 8 Aug 2015 21:41:33 +0200 Subject: [PATCH] Serialize errors before invoking postMessage Serialize errors to make sure that the callback is still invoked when an error is thrown. Firefox: "DataCloneError: The object could not be cloned." Chrome: "DataCloneError: Failed to execute 'postMessage' on 'WorkerGlobalScope': An object could not be cloned." --- src/shared/util.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/shared/util.js b/src/shared/util.js index 7edd0c2dd..b003b4a92 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -1504,6 +1504,10 @@ function MessageHandler(name, comObj) { data: result }); }, function (reason) { + if (reason instanceof Error) { + // Serialize error to avoid "DataCloneError" + reason = reason + ''; + } comObj.postMessage({ isReply: true, callbackId: data.callbackId,