diff options
author | stephan <stephan@noemail.net> | 2025-01-15 20:53:14 +0000 |
---|---|---|
committer | stephan <stephan@noemail.net> | 2025-01-15 20:53:14 +0000 |
commit | c738052394db4847c129c5039a973972e8125152 (patch) | |
tree | b2457081095a2662a765ced8e2c75f6c3cff28c9 /ext/wasm/api/extern-post-js.c-pp.js | |
parent | 874b5e9fbb22231b283ec5a56921fa9b418c5c8d (diff) | |
download | sqlite-c738052394db4847c129c5039a973972e8125152.tar.gz sqlite-c738052394db4847c129c5039a973972e8125152.zip |
Work around [https://github.com/emscripten-core/emscripten/issues/23420|a behavior change in emsdk 4.0.0] which breaks the load/init timing of the wasm module.
FossilOrigin-Name: 00a750184bcf1a94bf4e7f1d5029a42671e87e2997ae97be07bd900d3702883d
Diffstat (limited to 'ext/wasm/api/extern-post-js.c-pp.js')
-rw-r--r-- | ext/wasm/api/extern-post-js.c-pp.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ext/wasm/api/extern-post-js.c-pp.js b/ext/wasm/api/extern-post-js.c-pp.js index 63e55051c..c54e1f082 100644 --- a/ext/wasm/api/extern-post-js.c-pp.js +++ b/ext/wasm/api/extern-post-js.c-pp.js @@ -12,6 +12,7 @@ const toExportForESM = //#endif (function(){ + //console.warn("this is extern-post-js"); /** In order to hide the sqlite3InitModule()'s resulting Emscripten module from downstream clients (and simplify our @@ -62,6 +63,17 @@ const toExportForESM = globalThis.sqlite3InitModule = function ff(...args){ //console.warn("Using replaced sqlite3InitModule()",globalThis.location); return originalInit(...args).then((EmscriptenModule)=>{ + //console.warn("originalInit() then() arg =",EmscriptenModule); + //console.warn("initModuleState =",initModuleState); + if( EmscriptenModule.postRun && EmscriptenModule.postRun.length ){ + /* Emscripten 4.0.0 changes the order in which our Module.postRun handler + runs. In 3.x postRun would have run by now, and our code relies + heavily on that order, so we'll work around that difference here. + + https://github.com/emscripten-core/emscripten/issues/23420 */ + //console.warn("Emscripten did not run postRun: running them now!"); + EmscriptenModule.postRun.shift()(EmscriptenModule); + } //#if wasmfs if('undefined'!==typeof WorkerGlobalScope && EmscriptenModule['ENVIRONMENT_IS_PTHREAD']){ @@ -74,7 +86,6 @@ const toExportForESM = return EmscriptenModule; } //#endif - //console.warn("sqlite3InitModule() returning sqlite3 object."); const s = EmscriptenModule.sqlite3; s.scriptInfo = initModuleState; //console.warn("sqlite3.scriptInfo =",s.scriptInfo); |