Skip to content

Commit 296aae2

Browse files
committed
Improve timing of aborting in response to AbortSignals
Part of webmachinelearning/writing-assistance-apis#63. (Since detect() does not reuse the shared infrastructure, it needs its own parallel patch.)
1 parent a1caf65 commit 296aae2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

index.bs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ The <dfn attribute for="LanguageDetector">inputQuota</dfn> getter steps are to r
622622

623623
1. If |compositeSignal| is [=AbortSignal/aborted=], then return [=a promise rejected with=] |compositeSignal|'s [=AbortSignal/abort reason=].
624624

625+
1. Let |promise| be [=a new promise=] created in [=this=]'s [=relevant realm=].
626+
625627
1. Let |abortedDuringOperation| be false.
626628

627629
<p class="note">This variable will be written to from the [=event loop=], but read from [=in parallel=].
@@ -630,9 +632,9 @@ The <dfn attribute for="LanguageDetector">inputQuota</dfn> getter steps are to r
630632

631633
1. Set |abortedDuringOperation| to true.
632634

633-
1. Let |inputQuota| be [=this=]'s [=LanguageDetector/input quota=].
635+
1. [=Reject=] |promise| with |compositeSignal|'s [=AbortSignal/abort reason=].
634636

635-
1. Let |promise| be [=a new promise=] created in [=this=]'s [=relevant realm=].
637+
1. Let |inputQuota| be [=this=]'s [=LanguageDetector/input quota=].
636638

637639
1. [=In parallel=]:
638640

@@ -644,7 +646,7 @@ The <dfn attribute for="LanguageDetector">inputQuota</dfn> getter steps are to r
644646

645647
1. [=Queue a global task=] on the [=AI task source=] given |global| to perform the following steps:
646648

647-
1. If |abortedDuringOperation| is true, then [=reject=] |promise| with |compositeSignal|'s [=AbortSignal/abort reason=].
649+
1. If |abortedDuringOperation| is true, then abort these steps.
648650

649651
1. Otherwise, if |result| is an [=error information=], then [=reject=] |promise| with the result of [=converting error information into an exception object=] given |result|.
650652

0 commit comments

Comments
 (0)