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 rwasm/wasmrunnable.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (w *Runner) Run(job rt.Job, ctx *rt.Ctx) (interface{}, error) {

var output []byte
var runErr error
var callErr error

if err := w.env.UseInstance(ctx, func(instance *runtime.WasmInstance, ident int32) {
inPointer, writeErr := instance.WriteMemory(jobBytes)
Expand All @@ -75,8 +76,8 @@ func (w *Runner) Run(job rt.Job, ctx *rt.Ctx) (interface{}, error) {
}

// execute the Runnable's Run function, passing the input data and ident
// set runErr but don't return because the ExecutionResult error should override the Call error
_, runErr = instance.Call("run_e", inPointer, int32(len(jobBytes)), ident)
// set runErr but don't return because the ExecutionResult error should also be grabbed
_, callErr = instance.Call("run_e", inPointer, int32(len(jobBytes)), ident)

// get the results from the instance
output, runErr = instance.ExecutionResult()
Expand All @@ -93,6 +94,13 @@ func (w *Runner) Run(job rt.Job, ctx *rt.Ctx) (interface{}, error) {
return nil, runErr
}

if callErr != nil {
// if the runnable didn't return an explicit runErr, still check to see if there was an
// error executing the module in the first place. It's posslble for both to be non-nil
// in which case returning the runErr takes precedence, which is why it's checked first.
return nil, errors.Wrap(callErr, "wasm execution error")
}

if req != nil {
resp := &request.CoordinatedResponse{
Output: output,
Expand Down