Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream wit definition eliminates stream-error #6846

Merged
merged 2 commits into from
Aug 17, 2023
Merged

Conversation

pchickey
Copy link
Contributor

@pchickey pchickey commented Aug 14, 2023

In WebAssembly/wasi-io#38 we got review feedback to eliminate the stream-error in favor of the empty error (wit result<a>). Although upstream PR 38 is not merged yet, we are downstreaming this interface change now, expecting it will merge upstream soon.

The wit change means we cant use wasmtime-wit-bindgen's trappable_error functionality anymore, so the signature of the streams binding trait its call sites are much less idiomatic than before. We'll fix the wasmtime-wit-bindgen macro to support this case better in the future, but for now we can live with this code being a little ugly, since most users will be using the (much nicer) HostInputStream and HostOutputStream types.

As we made this change, it occurred to us that the host stream trait design doesn't distinguish between an error to be returned via a stream method at runtime, and an error that traps execution. We defined the StreamRuntimeError type for runtime errors, and all other errors trap.

@pchickey pchickey requested a review from a team as a code owner August 14, 2023 23:09
@pchickey pchickey requested review from jameysharp and elliottt and removed request for a team and jameysharp August 14, 2023 23:09
@pchickey pchickey requested a review from a team as a code owner August 14, 2023 23:47
@pchickey
Copy link
Contributor Author

pchickey commented Aug 15, 2023

TODO: need to rebase this on main once #6806 lands. done

@github-actions github-actions bot added the wasi Issues pertaining to WASI label Aug 15, 2023
In WebAssembly/wasi-io#38 we got review feedback
to eliminate the stream-error in favor of the empty error in wit
`result<a>`.

This means we cant use trappable error anymore, and therefore leads to
all this other unsightly transformation of the streams trait definition
and all its call sites.

We'll fix the wasmtime-wit-bindgen macro to support this case better in
the future, but rn we gotta stay synchronized with upstream

On the upside this showed us that the host stream trait design doesnt
differentiate between a runtime and a trapping error, so lets fix that
next

introduce a StreamRuntimeError, use it in filesystem streams

and fix an incorrect error transformation in the filesystem read impl

fill in fixmes for distinguishing a stream runtime error

delete outdated fixmes: downcast is now guaranteed by child resource tracking
Copy link
Member

@elliottt elliottt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I'm looking forward to the day that we can have custom impls for Try, as it would be great to remove the double-nesting of Result :)

@pchickey pchickey added this pull request to the merge queue Aug 16, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 16, 2023
…runtime

I don't think we should trap on any of the errors possible here,
reporting them as failures is sufficient
@pchickey pchickey added this pull request to the merge queue Aug 17, 2023
Merged via the queue into main with commit 96e3372 Aug 17, 2023
20 checks passed
@pchickey pchickey deleted the pch/no_more_stream_error branch August 17, 2023 21:37
eduardomourar pushed a commit to eduardomourar/wasmtime that referenced this pull request Aug 18, 2023
* stream wit definition eliminates stream-error

In WebAssembly/wasi-io#38 we got review feedback
to eliminate the stream-error in favor of the empty error in wit
`result<a>`.

This means we cant use trappable error anymore, and therefore leads to
all this other unsightly transformation of the streams trait definition
and all its call sites.

We'll fix the wasmtime-wit-bindgen macro to support this case better in
the future, but rn we gotta stay synchronized with upstream

On the upside this showed us that the host stream trait design doesnt
differentiate between a runtime and a trapping error, so lets fix that
next

introduce a StreamRuntimeError, use it in filesystem streams

and fix an incorrect error transformation in the filesystem read impl

fill in fixmes for distinguishing a stream runtime error

delete outdated fixmes: downcast is now guaranteed by child resource tracking

* dont try to detect rustix io error - just call all read/write errors runtime

I don't think we should trap on any of the errors possible here,
reporting them as failures is sufficient
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi Issues pertaining to WASI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants