-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(backoff): validate UnrecoverableError presence (#1074)
- Loading branch information
1 parent
d53a800
commit 1defeac
Showing
8 changed files
with
199 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
export * from './backoffs'; | ||
export * from './job'; | ||
export * from './queue-base'; | ||
export * from './queue-events'; | ||
export * from './queue-getters'; | ||
export * from './queue-scheduler'; | ||
export * from './queue'; | ||
export * from './redis-connection'; | ||
export * from './repeat'; | ||
export * from './scripts'; | ||
export * from './worker'; | ||
export * from './child-pool'; | ||
export * from './sandbox'; | ||
export * from './flow-producer'; | ||
export * from './backoffs'; | ||
export * from './job'; | ||
export * from './queue-base'; | ||
export * from './queue-events'; | ||
export * from './queue-getters'; | ||
export * from './queue-scheduler'; | ||
export * from './queue'; | ||
export * from './redis-connection'; | ||
export * from './repeat'; | ||
export * from './scripts'; | ||
export * from './worker'; | ||
export * from './child-pool'; | ||
export * from './sandbox'; | ||
export * from './flow-producer'; | ||
export * from './unrecoverable-error'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* UnrecoverableError | ||
* | ||
* Error to move a job to failed even if the attemptsMade | ||
* are lower than the expected limit. | ||
* | ||
*/ | ||
export class UnrecoverableError extends Error { | ||
constructor(message?: string) { | ||
super(message); | ||
this.name = this.constructor.name; | ||
Object.setPrototypeOf(this, new.target.prototype); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* A processor file to be used in tests. | ||
* | ||
*/ | ||
'use strict'; | ||
|
||
const { | ||
UnrecoverableError, | ||
} = require('../../dist/cjs/classes/unrecoverable-error'); | ||
const delay = require('./delay'); | ||
|
||
module.exports = function (job) { | ||
return delay(500).then(() => { | ||
if (job.attemptsMade < 2) { | ||
throw new Error('Not yet!'); | ||
} | ||
if (job.attemptsMade < 3) { | ||
throw new UnrecoverableError('Unrecoverable'); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters