Building Slack integration
This commit is contained in:
@@ -22,12 +22,27 @@ const backoffDelay = (attempt: number): number => {
|
||||
return window + Math.random() * window;
|
||||
};
|
||||
|
||||
/**
|
||||
* A job signals that retrying cannot change the outcome by throwing an error
|
||||
* carrying `permanent: true`. A revoked credential or a deleted channel is a
|
||||
* settled fact; spending the remaining attempts on it only delays every job
|
||||
* behind it and buries the real reason under retry noise.
|
||||
*/
|
||||
const isPermanent = (err: unknown): boolean =>
|
||||
typeof err === 'object' &&
|
||||
err !== null &&
|
||||
(err as { permanent?: unknown }).permanent === true;
|
||||
|
||||
const runEntry = async (entry: QueueEntry): Promise<void> => {
|
||||
for (let attempt = 1; ; attempt += 1) {
|
||||
try {
|
||||
await entry.job();
|
||||
return;
|
||||
} catch (err) {
|
||||
if (isPermanent(err)) {
|
||||
console.error(`[queue] job "${entry.name}" abandoned as permanent`, err);
|
||||
return;
|
||||
}
|
||||
if (attempt >= settings.maxAttempts) {
|
||||
console.error(
|
||||
`[queue] job "${entry.name}" abandoned after ${attempt} attempt(s)`,
|
||||
|
||||
Reference in New Issue
Block a user