Closed codefromthecrypt closed 2 years ago
this helps when a caller has a bunch of host modules, and prevents bookkeeping like this:
if wapc := m.wapc; wapc != nil {
_ = wapc.Close(ctx)
m.wapc = nil
}
if env := m.env; env != nil {
_ = env.Close(ctx)
m.env = nil
}
if wasi := m.wasi; wasi != nil {
_ = wasi.Close(ctx)
m.wasi = nil
}
@anuraaga @mathetake we probably need to decide if this will be an API or not. If it will, we should block 1.0 on it as it affects how people manage lifecycle.
+1 on Runtime.Close
, was hoping for it when initializing multiple modules.
+1
ok I'll add this to the blocker list
I noticed that users of wazero including ourselves often have a single imported module (WASI) and the one they made. To close requires them closing those in reverse order. I wonder if we can't have
Runtime.Close
which can do the same?An alternative would be if WASI could be special cased to never need closing. I don't know off the top of my head if we could pre-compile any glue needed and/or use offsets based on a go:embed FS or any other tricks to make WASI be safe to always be around.