WebAssembly / WebAssembly/WASI
Handling/forwarding `error-context`s that can be generated during a `body.finish`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 5.8k
- Forks
- 333
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 3
Description
During some implementation for error-contexts in futures in the wasip3-prototyping repo, we found that there was an issue with wasi:http/types#body.finish, as it implicitly does a future.read which can return a value or an error-context in the case of an error.
There are a few ways that we can solve this (thanks to @rvolosatovs and @dicej for suggestions), but a short incomplete list follows:
- Change the
finishmethod signature fromresult<option<trailers>, error-code>toresult<option<result<trailers, error-context>>,error-code> - Absorb the error and convert it into an existing
error-code(likelyinternal-error) - Create a new
error-codevariant that stores anerror-context
(1) is a reasonable approach but pollutes the type and possibly unreasonably forces caller to handle the error-context directly.
(2) causes some loss of context in an almost certain future version of error-context -- the best example is of an error context that can hold multiple traces (similar to an anyhow::Error), if we were to boil down the error context into only a string (given the current variants for error-code)
(3) Seems like an ideal option as a variation of (2) -- an additional error variant like internal-error-context(error-context) which would
There are of course other ways to handle this, so I'd like to open this up to discussion before submitting a PR to make the change (going for WebAssembly/wasi-http#3)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with wasi:http/types.wit at the body.finish definition around line 265, then read the Canonical ABI future.read behavior linked in the issue. Compare how body.finish can forward an error-context and review the proposed alternatives before checking WebAssembly/wasi-http#3. Done means an agreed handling approach is documented and ready for a PR.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- wasm
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100