Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarification on behavior of runInWorker #107

Open
jlipps opened this issue Dec 5, 2024 · 4 comments
Open

clarification on behavior of runInWorker #107

jlipps opened this issue Dec 5, 2024 · 4 comments
Assignees

Comments

@jlipps
Copy link

jlipps commented Dec 5, 2024

This minimal example:

import createPlugin from "@extism/extism";

async function main() {
  const plugin = await createPlugin('<some_wasm_file>', {useWasi: true, runInWorker: true});
}

main().catch(console.error);

Will hang, unless I call plugin.close(). Without runInWorker set to true, the process will terminate on its own, without calling plugin.close(). Is this expected? If so, it might be worth calling out in the docs as a usage distinction.

@bhelx
Copy link
Contributor

bhelx commented Dec 6, 2024

@chrisdickinson i made the assumption that plugin going out of scope would close it. but maybe not? Or is plugin just not going out of scope here? i'm not really sure how node does top-level async maybe node is not closing because main is not being awaited?

@bhelx
Copy link
Contributor

bhelx commented Dec 6, 2024

if close() must be called we should probably get that spelled out in docs somewhere.

@chrisdickinson
Copy link
Contributor

Good catch! Yes, close() is required when runInWorker: true. I'll add it to the docs! (In the future, we might use a FinalizationRegistry to do the cleanup for us.)

@jlipps
Copy link
Author

jlipps commented Dec 6, 2024

Great, thanks for the clarification :-) Feel free to leave this open to track the docs update or close--I'm all set on my end!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants