Skip to content

fix: add ReadableStream write fn#537

Closed
vados-cosmonic wants to merge 1 commit into
WebAssembly:mainfrom
vados-cosmonic:fix=add-readablestream-write
Closed

fix: add ReadableStream write fn#537
vados-cosmonic wants to merge 1 commit into
WebAssembly:mainfrom
vados-cosmonic:fix=add-readablestream-write

Conversation

@vados-cosmonic
Copy link
Copy Markdown
Collaborator

@vados-cosmonic vados-cosmonic commented Jun 26, 2025

ReadableStream.write appeared to be missing from the docs -- it should work near identically to read (except for internal implementation of course), but wasn't called out.

Signed-off-by: Victor Adossi <vadossi@cosmonic.com>
@lukewagner
Copy link
Copy Markdown
Member

Thanks for the careful read. The reason write isn't in ReadableStream is that a ReadableStream that comes from the host really doesn't have a write -- you can only read it (see this comment). Now I'm guessing you're looking at the fact that the shared field of StreamEnd has type ReadableStream while the WritableStreamEnd subclass calls write on it. This weirdness is addressed in this comment. If there were a WritableStream interface (symmetric to ReadableStream), we could say the type of shared is ReadableStream|WritableStream (which would still be a little imprecise, for lack of covariance, but better). I didn't do that before b/c it didn't seem worth it just for this one type annotation, but thinking about it again, probably it's a good idea and it could be added to the base-class list of SharedStreamImpl alongside ReadableStream which would be useful too. I'll do that in a separate PR (b/c it'll probably involve a bit of prose refactoring).

@vados-cosmonic
Copy link
Copy Markdown
Collaborator Author

Ah thank you for the explanation -- I certainly added this because of seeing the ReadableStream being in there! I'll let you get to updating that when you're ready :)

@lukewagner lukewagner mentioned this pull request Jun 26, 2025
@vados-cosmonic vados-cosmonic deleted the fix=add-readablestream-write branch June 27, 2025 05:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants