Skip to content

Commit 8cb33f2

Browse files
committed
Clarify closing states
1 parent 40c60c8 commit 8cb33f2

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

index.bs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,8 @@ The synchronous methods ({{Writer/writeSync()}}, {{Writer/writevSync()}}) operat
547547

548548
The asynchronous methods ({{Writer/write()}}, {{Writer/writev()}}) first attempt to place the batch into the slots buffer. If the slots buffer is full, the write is placed into the pending writes queue (for `"strict"` and `"block"` policies). When the consumer reads and frees slots, pending writes are promoted from the pending queue into the slots buffer in order, and their promises resolve.
549549

550+
If the bonded readable's consumer stops iterating (the async iterator returns or throws), the writer's consumer is no longer <dfn>active</dfn>. Subsequent synchronous writes return `false` and asynchronous writes reject, since the data has no consumer to receive it.
551+
550552
### `Writer.desiredSize` ### {#writer-desiredsize}
551553

552554
<div algorithm>
@@ -564,8 +566,9 @@ The <dfn method for="Writer">write(chunk, options)</dfn> method writes a single
564566

565567
<ol>
566568
<li>If |chunk| is a {{USVString}}, set |chunk| to the result of [=UTF-8 encode|UTF-8 encoding=] |chunk|.
567-
<li>If the writer is closed, return [=a promise rejected with=] a {{TypeError}}.
569+
<li>If the writer is closed or [=closing=], return [=a promise rejected with=] a {{TypeError}}.
568570
<li>If the writer is errored, return [=a promise rejected with=] the stored error.
571+
<li>If the bonded consumer is not [=active=], return [=a promise rejected with=] a {{TypeError}} (or, if the consumer's iterator threw an error, reject with that error).
569572
<li>If |options|["{{WriteOptions/signal}}"] is present and [=AbortSignal/aborted=], return [=a promise rejected with=] its abort reason.
570573
<li>Let |batch| be « |chunk| ».
571574
<li>If the slots buffer has space, enqueue |batch|, [=notify drain waiters=], and return [=a promise resolved with=] `undefined`.
@@ -593,7 +596,7 @@ The <dfn method for="Writer">writeSync(chunk)</dfn> method attempts a synchronou
593596

594597
<ol>
595598
<li>If |chunk| is a {{USVString}}, set |chunk| to the result of [=UTF-8 encode|UTF-8 encoding=] |chunk|.
596-
<li>If the writer is closed or errored, return `false`.
599+
<li>If the writer is closed, [=closing=], or errored, or if the bonded consumer is not [=active=], return `false`.
597600
<li>Let |batch| be « |chunk| ».
598601
<li>If the slots buffer has space, enqueue |batch|, [=notify drain waiters=], and return `true`.
599602
<li>The slots buffer is full. Proceed based on the [=backpressure policy=]:

0 commit comments

Comments
 (0)