This repository was archived by the owner on Mar 13, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -37,10 +37,11 @@ export const AbortSignal =
3737 globalThis . AbortSignal ??
3838 Object . getPrototypeOf ( new AbortController ( ) . signal ) . constructor ;
3939
40- // Polyfill `AbortSignal.timeout` as described here:
40+ // Replace `AbortSignal.timeout` as described here:
4141// https://community.cloudflare.com/t/2021-12-10-workers-runtime-release-notes/334982
42- // @ts -expect-error `timeout` isn't included in Node.js yet
43- AbortSignal . timeout ??= function ( ms ?: number ) {
42+ // @ts -expect-error `timeout` was added in Node 17.3.0
43+ AbortSignal . timeout = function ( ms ?: number ) {
44+ // Confusingly, `timeout` allows `timeout(undefined)`, but not `timeout()`
4445 if ( arguments . length === 0 ) {
4546 throw new TypeError (
4647 "Failed to execute 'timeout' on 'AbortSignal': parameter 1 is not of type 'integer'."
@@ -57,6 +58,7 @@ export interface SchedulerWaitOptions {
5758
5859export class Scheduler {
5960 wait ( ms ?: number , options ?: SchedulerWaitOptions ) : Promise < void > {
61+ // Confusingly, `wait` allows `wait(undefined)`, but not `wait()`
6062 if ( arguments . length === 0 ) {
6163 throw new TypeError (
6264 "Failed to execute 'wait' on 'Scheduler': parameter 1 is not of type 'integer'."
Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ test("AbortSignal.timeout: requires numeric timeout", (t) => {
124124test ( "AbortSignal.timeout: included on constructor obtained via AbortController#signal prototype" , ( t ) => {
125125 const controller = new AbortController ( ) ;
126126 const constructor = Object . getPrototypeOf ( controller . signal ) . constructor ;
127- // @ts -expect-error `timeout` isn't included in Node.js yet
127+ // @ts -expect-error `timeout` was added in Node 17.3.0
128128 t . is ( constructor . timeout , AbortSignal . timeout ) ;
129129} ) ;
130130
You can’t perform that action at this time.
0 commit comments