Skip to content

fix: add ReadableStream write fn #537

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

Conversation

vados-cosmonic
Copy link
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.

@lukewagner
Copy link
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
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