Unable to initialize scran.js, probably missing something!
Closed this issue · 6 comments
The simplest possible test program seems to fail for me (both on OS X — and x86 Mac — and on linux). I tired the script below:
import * as scran from "scran.js"
await scran.initialize({ numberOfThreads: 4 })
with package.json
:
{
"type": "module",
"dependencies": {
"scran.js": "^2.0.3"
}
}
and on both platforms I get the following (absurdly long) error:
It looks like it prints line 15 of scran.js
and then provides the above backtrace. Any ideas what is going wrong?
Thanks!
Rob
What's your version of Node? On older versions, you'll need a stack of flags; I don't remember them all, but it's something like:
--experimental-wasm-threads
--experimental-wasm-bulk-memory
--experimental-wasm-bigint
Old Nodes also need:
await scran.initialize({ numberOfThreads: 4, localFile: true })
because they don't know how to handle file://
URIs.
Finally, you'll need to add a await scran.terminate();
if you want the program to actually end, as Node doesn't want to shut down while there's still workers spinning around. This should be fixed in the latest version of Emscripten but we haven't updated to the latest toolchain yet.
So, in total, the following works for me on Node.js v16.19.1:
import * as scran from "scran.js"
await scran.initialize({ numberOfThreads: 4, localFile: true })
await scran.terminate();
This is Node 19.02. Is that too new?
I am on a newer version of node (19.6.1) and I had to enable these flags
⋊> ~/P/p/k/rob_test node --experimental-wasm-modules --no-experimental-fetch --experimental-wasm-threads --experimental-modules index.js
and my index.js
import * as scran from "scran.js";
await scran.initialize({ numberOfThreads: 4, localFile: true });
console.log("i can load");
await scran.terminate()
every time node updates, we need to figure out the new set of flags to enable these cutting edge "experimental" features :)
Hi @jkanche,
Thanks; it works with the flags you provide! By the way, with Node 19, is there a reason we still need to provide localFile: true
(it doesn't seem to work without this).
Thanks!
Rob
i believe we still need to have this patch in our code.
It still seems to be a problem even though emscripten seems to fix it. - emscripten-core/emscripten#10434.