Summary
engines/extism/evaluator/evaluator.go:79-82:
if exit != 0 {
// TODO should we return the output in this case?
return nil, execTime, fmt.Errorf("function returned non-zero exit code: %d", exit)
}
When a WASM function returns non-zero, the output bytes are discarded. This makes diagnosing a misbehaving plugin harder than it needs to be — the plugin may have written a structured error to its output buffer that we're throwing away.
Proposal
Two options:
-
Include a quoted/truncated form of the output in the error message: function returned non-zero exit code: %d (output: %q).
-
Expose an ExitError type:
type ExitError struct {
ExitCode int32
Output []byte
}
so callers can errors.As and inspect the output.
(2) is more useful long-term but is a public-API addition, so probably belongs together with the v1 EvaluatorResponse work.
Files
engines/extism/evaluator/evaluator.go:62-101
Summary
engines/extism/evaluator/evaluator.go:79-82:When a WASM function returns non-zero, the output bytes are discarded. This makes diagnosing a misbehaving plugin harder than it needs to be — the plugin may have written a structured error to its output buffer that we're throwing away.
Proposal
Two options:
Include a quoted/truncated form of the output in the error message:
function returned non-zero exit code: %d (output: %q).Expose an
ExitErrortype:so callers can
errors.Asand inspect the output.(2) is more useful long-term but is a public-API addition, so probably belongs together with the v1
EvaluatorResponsework.Files
engines/extism/evaluator/evaluator.go:62-101