From 3a0cfd668eaa7b1badcea8baba13829d504cae4f Mon Sep 17 00:00:00 2001
From: Domenic Denicola
To error a {{WritableStream}} |stream| given a JavaScript value |e|, perform ! [$WritableStreamDefaultControllerErrorIfNeeded$](|stream|.[=WritableStream/[[controller]]=], |e|). +
The signal of a {{WritableStream}} |stream| is +|stream|.[=WritableStream/[[controller]]=].[=WritableStreamDefaultController/[[signal]]=]. +Specifications can [=AbortSignal/add=] or [=AbortSignal/remove=] algorithms to this +{{AbortSignal}}, or consult whether it is [=AbortSignal/aborted=] and its [=AbortSignal/abort +reason=]. Specifications should not [=AbortSignal/signal abort=] or make it [=AbortSignal/follow=] +another {{AbortSignal}}, as that would interfere with the normal use of this signal to respond to +the stream being [=abort a writable stream|aborted=]. + +
The usual usage is, after [=WritableStream/setting up=] the {{WritableStream}}, +[=AbortSignal/add=] an algorithm to its [=WritableStream/signal=], which aborts any ongoing write +operation to the [=underlying sink=]. Then, inside the [=WritableStream/set +up/writeAlgorithm=], once the [=underlying sink=] has responded, check if the +[=WritableStream/signal=] is [=AbortSignal/aborted=], and [=reject=] the returned promise with the +signal's [=AbortSignal/abort reason=] if so. +