clarification on behavior of `runInWorker`
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.
@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?
if close() must be called we should probably get that spelled out in docs somewhere.
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.)
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!