From 5f015eac9cbc2b7901a9aa76dab638ea3c60d6f8 Mon Sep 17 00:00:00 2001 From: yonatan ben avraham Date: Fri, 8 Jan 2021 16:44:24 +0200 Subject: fix: Worker hangs when posting "undefined" as message (#8920) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes hang in web workers occuring when sending "undefined" as message value. It is a temporary band-aid until proper structured close is implemented. Co-authored-by: Bartek IwaƄczuk --- runtime/js/11_workers.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'runtime/js') diff --git a/runtime/js/11_workers.js b/runtime/js/11_workers.js index 57f420728..e943d66bc 100644 --- a/runtime/js/11_workers.js +++ b/runtime/js/11_workers.js @@ -47,6 +47,13 @@ } function decodeMessage(dataIntArray) { + // Temporary solution until structured clone arrives in v8. + // Current clone is made by parsing json to byte array and from byte array back to json. + // In that case "undefined" transforms to empty byte array, but empty byte array does not transform back to undefined. + // Thats why this special is statement is needed. + if (dataIntArray.length == 0) { + return undefined; + } const dataJson = decoder.decode(dataIntArray); return JSON.parse(dataJson); } -- cgit v1.2.3