diff options
author | yonatan ben avraham <ybenavraham@outbrain.com> | 2021-01-08 16:44:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 15:44:24 +0100 |
commit | 5f015eac9cbc2b7901a9aa76dab638ea3c60d6f8 (patch) | |
tree | 885c397d867ea5473877135b6d849522f42e86df /runtime/js/11_workers.js | |
parent | a44349dfdfecacdd4ccd343a984b05abb728bf88 (diff) |
fix: Worker hangs when posting "undefined" as message (#8920)
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 <biwanczuk@gmail.com>
Diffstat (limited to 'runtime/js/11_workers.js')
-rw-r--r-- | runtime/js/11_workers.js | 7 |
1 files changed, 7 insertions, 0 deletions
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); } |