Bootstrapping a minimal node-compatible runtime
I'm trying to bootstrap a minimal node-compatible runtime, so I've basically been copying and pasting
MainWorker
and removing things I don't need like napi
or kv
However when it crashes on JsRuntime::new
Is there anything I seem to be missing that could cause this error?4 Replies
Based on the documentation, the error message you're seeing suggests that a module or extension has been evaluated more than once. This could happen if you're including a module or extension in your runtime that's already included in a snapshot you're using.
The
JsRuntime::new
function is used to create a new JavaScript runtime with the specified options. In your case, it seems like one of the extensions you're adding to your runtime is causing the issue.
The extensions you're adding with init_ops_and_esm
are initializing both the ops and the ECMAScript modules for various Deno features. If one of these extensions is already included in a snapshot you're using, it could cause the module to be evaluated twice, leading to the error you're seeing.
Without more information about your setup, it's hard to say exactly which extension is causing the issue. However, you could try commenting out each extension one by one to see which one is causing the error. Once you've identified the problematic extension, you can investigate further to see why it's being evaluated twice.
Remember that this advice is not explicitly stated in the documentation, but it's a general debugging approach that could help you identify the issue.You using a snapshot to init the runtime?
If so just use init_ops not init_ops_and_esm
The esm is already in the snapshot
Thanks, that seems to work
Happy to help