wasm: structured errors, safe interrupts, bump golang and wasmtime-go (#3391)
* topdown/errors: use 1.13+ error wrapping
The topdown.IsCancel() and topdown.IsError() functions thereby learn
to figure out type error type even if the error had been wrapped. We
don't make use of this right now, but it's nice to follow the stdlib
expectations.
For more information, see https://blog.golang.org/go1.13-errors
* go: bump to 1.16, keep compat with 1.15
See https://golang.org/ref/mod#go-mod-file-go about the `go` directive in
`go.mod`:
> A go directive indicates that a module was written assuming the semantics
> of a given version of Go.
* wasm-sdk: improve errors
We'll now return properly structured objects, with code+message:
$ opa test -t wasm --timeout 1s . -v
data.p.test_that_takes_long: ERROR (1.004488054s)
cancelled: interrupted at eval/g0.data.p.test_that_takes_long/opa_numbers_range/qadd_one/mpd_del/free/opa_free
--------------------------------------------------------------------------------
ERROR: 1/1
$ opa test -t wasm --timeout 1s . -v --format=json
[
{
"location": {
"file": "t.rego",
"row": 3,
"col": 1
},
"package": "data.p",
"name": "test_that_takes_long",
"error": {
"code": "cancelled",
"message": "interrupted at eval/g0.data.p.test_that_takes_long/opa_numbers_range/opa_array_append"
},
"duration": 1003761215
}
]
The interrupt stacktrace is an attempt to provide some useful information,
similar to the topdown case; but the scene naturally looks different in wasm.
Fixes #3225.
Also changes the goroutine setup in vm.go to conform to the wasmtime-go folks'
hints on what to share in goroutines and what not to (the store).
* deps: bump wasmtime-go v0.26.0 -> v0.26.1
Signed-off-by: Stephan Renatus <stephan.renatus@gmail.com> S
Stephan Renatus committed
82cca627647165804f8cf042cfd7f84dd13ddecc
Parent: ec6d653
Committed by GitHub <noreply@github.com>
on 5/5/2021, 2:35:42 PM