From e65eb1b5f68562fc2754e319cb04d36c119bc70c Mon Sep 17 00:00:00 2001 From: Jason Gross Date: Thu, 23 Nov 2023 12:06:57 -0800 Subject: [PATCH] Work around asnyc wasm code cf https://github.com/ocaml-wasm/wasm_of_ocaml/issues/11 --- fiat-html/wasm_fiat_crypto_worker.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/fiat-html/wasm_fiat_crypto_worker.js b/fiat-html/wasm_fiat_crypto_worker.js index f596fc6aa6e..1e0f747f2af 100644 --- a/fiat-html/wasm_fiat_crypto_worker.js +++ b/fiat-html/wasm_fiat_crypto_worker.js @@ -1,9 +1,15 @@ self.importScripts("wasm_fiat_crypto.js"); -self.onmessage = function(e) { - try { - const result = synthesize(e.data); - postMessage({result: result}); - } catch (err) { - postMessage({error: err}); - } -}; +let pending = []; +self.onmessage = function (e) { pending.push(e); }; +setTimeout(function () { + self.onmessage = function(e) { + try { + const result = synthesize(e.data); + postMessage({result: result}); + } catch (err) { + postMessage({error: err}); + } + }; + pending.forEach(e => { self.onmessage(e); }); + pending = []; +}, 1000);