-
Notifications
You must be signed in to change notification settings - Fork 163
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
Add WritableStream#write convenience method #1339
base: main
Are you sure you want to change the base?
Conversation
The fact that parallel writes wouldn't be allowed (since each write locks the writable) is a bit of a challenge here. I'm not entirely convinced that this is the right thing to add. Can you expand on the motivating use cases a bit more? |
<div algorithm> | ||
The <dfn id="ws-write" method for="WritableStream">write(|chunk|)</dfn> method steps are: | ||
|
||
1. Let |result| be ? [$AcquireWritableStreamDefaultWriter$]([=this=]). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be worth introducing a new abstract op WritableStreamWrite(stream, chunk)
for doing a "writer-less write", similar to WritableStreamAbort
and WritableStreamClose
. We could then rework WritableStreamDefaultWriterWrite
to use the same abstract op, similar to how WritableStreamDefaultWriterAbort
delegates to WritableStreamAbort
.
(We may have to take chunkSize
as an extra argument though, since step 5 of WritableStreamDefaultWriterWrite
might be difficult to implement otherwise.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do that if I can get implementer interest :)
I'm looking for implementer interest for this change. How are Chromium, Gecko, WebKit, and Cloudflare folks feeling about this? @saschanaz @domenic @jasnell @annevk |
@jasnell Yeah see the first thread on this PR. I changed it to do |
Nit: please change the commit/PR title to make this not look like it's adding a static method. |
Is it the same as https://fs.spec.whatwg.org/#dom-filesystemwritablefilestream-write? |
@youennf Yes (but for all |
I'm interested to have this to replace Bucket FS side equivalent. cc @janvarga |
delegating to @jjjalkanen |
@lucacasonato Cloudflare will implement if this moves forward. I'm not super convinced of the use cases yet as I haven't had anyone ask for this but I certainly don't have a reason not to support it. |
If this is happening we should probably remove/refactor |
I'm in favor of this but for Chromium it's @ricea and @nidhijaju who would be doing the work, so please wait for one of them to confirm. |
Add a WriteableStream.write convenience method to write a single chunk. It locks, writes, then unlocks all in one call.
Towards #1072
(See WHATWG Working Mode: Changes for more details.)
Preview | Diff