From 19828dd329ed90cce14d5979e358ce57bbe32088 Mon Sep 17 00:00:00 2001 From: Ryan Lester Date: Tue, 6 Mar 2018 01:48:25 -0500 Subject: [PATCH] run-time wasm test before resolving ready --- dist-build/emscripten.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dist-build/emscripten.sh b/dist-build/emscripten.sh index 82c29485..06f2dd47 100755 --- a/dist-build/emscripten.sh +++ b/dist-build/emscripten.sh @@ -99,7 +99,15 @@ if [ "$DIST" = yes ]; then Module.ready = new Promise(function (resolve, reject) { var Module = _Module; Module.onAbort = reject; - Module.onRuntimeInitialized = resolve; + Module.onRuntimeInitialized = function () { + try { + /* Test arbitrary wasm function */ + Module._crypto_stream_chacha20_keybytes(); + resolve(); + } catch (err) { + reject(err); + } + }; $(cat "${PREFIX}/lib/libsodium.wasm.tmp.js") }).catch(function () { var Module = _Module;