-
Notifications
You must be signed in to change notification settings - Fork 23
Proposal: add output-stream::(blocking-)close
#86
Conversation
|
If I understand this correctly, this would add an effective requirement for consumers of APIs that have For example, the Besides compatibility with Preview 2 APIs, there's also the question of how this could be implemented. No major programming language today expects users to do the equivalent of calling |
I conceptualize
In the case of |
|
I'm concerned about |
|
I'd say: Discard it. (*) = Actually, POSIX' |
|
The fact that many applications ignore errors from |
|
From talking with @lukewagner about Preview 3, it's likely that Preview 3 streams won't have an equivalent of a fallible As background, the idea for Preview 3 streams is that there won't be a separate input-stream and output-stream that can't be directly composed with each other. There's just a Pure stream transfomers could have a signture like That's quite different than the simple resource-based |
|
After discussing this further in person, my current understanding is that with Preview 3 streams:
Mapping this back to Preview 2 streams: input-stream
In terms of WIT, a P2 signature of: receive: func() -> input-stream;can be trivially converted to P3 like so: receive: func() -> stream<u8, error>;
|
|
Thank you for contributing to WASI! As part of our proposal management process, we decided to consolidate all phase 3 proposals into a single monorepo at WebAssembly/wasi to better manage the proposals that have reached phase 3. We have completed migrating all phase 3 proposals to WebAssembly/wasi including their issues, but PRs need to be re-opened in the new repository. This is a GitHub limitation and we're sorry for the inconvenience. Please re-open this PR on WebAssembly/wasi. Thank you! |
Today, there is no generic way to gracefully close a stream, other than to
dropit and hope for the best.Wasi-sockets already has an ad-hoc workaround in the form of
tcp-socket::shutdown(send). Similarly (but not exactly the same), wasi-http hasoutgoing-body::finish.I'm currently sketching out a TLS interface for WASI, where the TLS client/server does not perform any I/O on its own but instead acts as a stream transformer: cleartext data goes in, TLS data comes out, and vice versa. The stream transformer should not have to know where its inputs & outputs come from and go to. One thing that differentiates TLS from plain TCP is that a graceful shutdown requires additional I/O (a "close_notify" message to be sent).
One way to go about this is to add yet another set of bespoke methods on the TLS client/server resource type to close the output streams.
But preferably the end-of-stream indication should be propagated automagically.
I propose to add the ability to explicitly shut down a writable stream, asynchronously. This is not too far off from how existing programming environments work:
futures::io::AsyncWrite::poll_closetokio::io::AsyncWrite::poll_shutdownSystem.IO.Stream.DisposeAsyncstream.Writable.endasyncDispose(stage 3 proposal)asyncio.StreamWriter.close + wait_close