Skip to content

Commit

Permalink
fix: make yomo_wanted_target function optional in wasm (#980)
Browse files Browse the repository at this point in the history
# Description

This is a bug fix pr which allows wasm runtimes do NOT implement
`yomo_wanted_target ` function.
  • Loading branch information
wujunzhuo authored Dec 26, 2024
1 parent ba744f6 commit 11f2e9c
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions cli/serverless/wasm/wazero.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,13 @@ func (r *wazeroRuntime) Init(wasmFile string) error {
}

wantedTargetFunc := module.ExportedFunction(WasmFuncWantedTarget)
if wantedTargetFunc == nil {
return fmt.Errorf("%s function not found", WasmFuncWantedTarget)
}
if _, err := wantedTargetFunc.Call(r.ctx); err != nil {
if exitErr, ok := err.(*sys.ExitError); ok && exitErr.ExitCode() != 0 {
return fmt.Errorf("%s.Call: %v", WasmFuncWantedTarget, err)
} else if !ok {
return fmt.Errorf("%s.Call: %v", WasmFuncWantedTarget, err)
if wantedTargetFunc != nil {
if _, err := wantedTargetFunc.Call(r.ctx); err != nil {
if exitErr, ok := err.(*sys.ExitError); ok && exitErr.ExitCode() != 0 {
return fmt.Errorf("%s.Call: %v", WasmFuncWantedTarget, err)
} else if !ok {
return fmt.Errorf("%s.Call: %v", WasmFuncWantedTarget, err)
}
}
}

Expand Down

0 comments on commit 11f2e9c

Please sign in to comment.