Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions services/api/internal/platform/plugin/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,16 @@ func (r *Runtime) Load(ctx context.Context, p plugindom.Plugin) error {
_ = wasmRT.Close(ctx)
return fmt.Errorf("runtime load %q: compile: %w", p.Name, err)
}
// For WASI reactor builds, _initialize must be called before exported functions
mod, err := wasmRT.InstantiateModule(ctx, compiled, wazero.NewModuleConfig().WithName(p.Name).WithStartFunctions("_initialize"))
// For WASI reactor builds, _initialize must be called before exported functions.
// WithSysWalltime/WithSysNanotime wire the module's clock to the real OS
// clock; without them wazero silently falls back to a fake clock frozen at
// 1970-01-01 (nanotime) / 2022-01-01 (walltime), which is what plugins would
// otherwise observe from time.Now() — see issue #339.
mod, err := wasmRT.InstantiateModule(ctx, compiled, wazero.NewModuleConfig().
WithName(p.Name).
WithStartFunctions("_initialize").
WithSysWalltime().
WithSysNanotime())
if err != nil {
_ = wasmRT.Close(ctx)
return fmt.Errorf("runtime load %q: instantiate: %w", p.Name, err)
Expand Down
Loading