diff --git a/bottleneck.d.ts b/bottleneck.d.ts index 0540b5c..e074b1b 100644 --- a/bottleneck.d.ts +++ b/bottleneck.d.ts @@ -491,7 +491,7 @@ declare module "bottleneck" { on(name: "queued", fn: (info: Bottleneck.EventInfoQueued) => void): void; on(name: "scheduled", fn: (info: Bottleneck.EventInfo) => void): void; on(name: "executing", fn: (info: Bottleneck.EventInfoRetryable) => void): void; - on(name: "failed", fn: (error: any, info: Bottleneck.EventInfoRetryable) => Promise | number | void): void; + on(name: "failed", fn: (error: any, info: Bottleneck.EventInfoRetryable) => Promise | number | void | null): void; on(name: "retry", fn: (message: string, info: Bottleneck.EventInfoRetryable) => void): void; on(name: "done", fn: (info: Bottleneck.EventInfoRetryable) => void): void; @@ -511,7 +511,7 @@ declare module "bottleneck" { once(name: "queued", fn: (info: Bottleneck.EventInfoQueued) => void): void; once(name: "scheduled", fn: (info: Bottleneck.EventInfo) => void): void; once(name: "executing", fn: (info: Bottleneck.EventInfoRetryable) => void): void; - once(name: "failed", fn: (error: any, info: Bottleneck.EventInfoRetryable) => Promise | number | void): void; + once(name: "failed", fn: (error: any, info: Bottleneck.EventInfoRetryable) => Promise | number | void | null): void; once(name: "retry", fn: (message: string, info: Bottleneck.EventInfoRetryable) => void): void; once(name: "done", fn: (info: Bottleneck.EventInfoRetryable) => void): void; diff --git a/bottleneck.d.ts.ejs b/bottleneck.d.ts.ejs index 8af8de3..bb17c63 100644 --- a/bottleneck.d.ts.ejs +++ b/bottleneck.d.ts.ejs @@ -491,7 +491,7 @@ declare module "bottleneck" { on(name: "queued", fn: (info: Bottleneck.EventInfoQueued) => void): void; on(name: "scheduled", fn: (info: Bottleneck.EventInfo) => void): void; on(name: "executing", fn: (info: Bottleneck.EventInfoRetryable) => void): void; - on(name: "failed", fn: (error: any, info: Bottleneck.EventInfoRetryable) => Promise | void): void; + on(name: "failed", fn: (error: any, info: Bottleneck.EventInfoRetryable) => Promise | number | void | null): void; on(name: "retry", fn: (message: string, info: Bottleneck.EventInfoRetryable) => void): void; on(name: "done", fn: (info: Bottleneck.EventInfoRetryable) => void): void; @@ -511,7 +511,7 @@ declare module "bottleneck" { once(name: "queued", fn: (info: Bottleneck.EventInfoQueued) => void): void; once(name: "scheduled", fn: (info: Bottleneck.EventInfo) => void): void; once(name: "executing", fn: (info: Bottleneck.EventInfoRetryable) => void): void; - once(name: "failed", fn: (error: any, info: Bottleneck.EventInfoRetryable) => Promise | void): void; + once(name: "failed", fn: (error: any, info: Bottleneck.EventInfoRetryable) => Promise | number | void | null): void; once(name: "retry", fn: (message: string, info: Bottleneck.EventInfoRetryable) => void): void; once(name: "done", fn: (info: Bottleneck.EventInfoRetryable) => void): void; diff --git a/test.ts b/test.ts index 4b348fa..bf064a7 100644 --- a/test.ts +++ b/test.ts @@ -119,6 +119,40 @@ limiter.on('failed', (error, info) => { return Promise.resolve(10) }) +limiter.on('failed', (error, info) => { + checkEventInfo(info) + const message: string = error.message; + const count: number = info.retryCount; + return Promise.resolve(null) +}) + +limiter.on('failed', (error, info) => { + checkEventInfo(info) + const message: string = error.message; + const count: number = info.retryCount; + return Promise.resolve() +}) + +limiter.on('failed', (error, info) => { + checkEventInfo(info) + const message: string = error.message; + const count: number = info.retryCount; + return 10 +}) + +limiter.on('failed', (error, info) => { + checkEventInfo(info) + const message: string = error.message; + const count: number = info.retryCount; + return null +}) + +limiter.on('failed', (error, info) => { + checkEventInfo(info) + const message: string = error.message; + const count: number = info.retryCount; +}) + limiter.on('retry', (message: string, info) => { checkEventInfo(info) const count: number = info.retryCount;