Skip to content

Commit 53282dd

Browse files
committed
Fix documentation for underlying source cancel() errors
See nodejs/node#41048. This spells out the motivation for the difference between cancel and close/abort while we're here.
1 parent 7f7d68b commit 53282dd

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

index.bs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,9 +625,21 @@ enum ReadableStreamType { "bytes" };
625625
example [[#example-rs-push-no-backpressure]].
626626

627627
<p>If the shutdown process is asynchronous, it can return a promise to signal success or failure;
628-
the result will be communicated via the return value of the <code>cancel()</code>
629-
method that was called. Additionally, a rejected promise will error the stream, instead of
630-
letting it close. Throwing an exception is treated the same as returning a rejected promise.
628+
the result will be communicated via the return value of the <code>cancel()</code> method that was
629+
called. Throwing an exception is treated the same as returning a rejected promise.
630+
631+
<div class="note">
632+
<p>Even if the cancelation process fails, the stream will still close; it will not be put into
633+
an errored state. This is because a failure in the cancelation process doesn't matter to the
634+
consumer's view of the stream, once they've expressed disinterest in it by canceling. The
635+
failure is only communicated to the immediate caller of the corresponding method.
636+
637+
<p>This is different from the behavior of the {{UnderlyingSink/close}} and
638+
{{UnderlyingSink/abort}} options of a {{WritableStream}}'s [=underlying sink=], which upon
639+
failure put the corresponding {{WritableStream}} into an errored state. Those correspond to
640+
specific actions the [=producer=] is requesting and, if those actions fail, they indicate
641+
something more persistently wrong.
642+
</div>
631643

632644
<dt><dfn dict-member for="UnderlyingSource" lt="type"><code>type</code></dfn> (byte streams
633645
only)</dt>

0 commit comments

Comments
 (0)