fix: Add recording of job errors, remove from queues on failure, centralize options
This commit is contained in:
@ -240,7 +240,6 @@ export class Mailer {
|
||||
},
|
||||
{
|
||||
attempts: 5,
|
||||
removeOnComplete: true,
|
||||
backoff: {
|
||||
type: "exponential",
|
||||
delay: 60 * 1000,
|
||||
|
@ -14,7 +14,6 @@ export default class DebounceProcessor {
|
||||
},
|
||||
{
|
||||
delay: 5 * 60 * 1000,
|
||||
removeOnComplete: true,
|
||||
}
|
||||
);
|
||||
break;
|
||||
@ -30,13 +29,10 @@ export default class DebounceProcessor {
|
||||
// this functions as a simple distributed debounce.
|
||||
if (document.updatedAt > new Date(event.createdAt)) return;
|
||||
|
||||
globalEventQueue.add(
|
||||
{
|
||||
...event,
|
||||
name: "documents.update.debounced",
|
||||
},
|
||||
{ removeOnComplete: true }
|
||||
);
|
||||
globalEventQueue.add({
|
||||
...event,
|
||||
name: "documents.update.debounced",
|
||||
});
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -3,6 +3,7 @@ import Queue from "bull";
|
||||
import Redis from "ioredis";
|
||||
import { snakeCase } from "lodash";
|
||||
import { client, subscriber } from "../redis";
|
||||
import Sentry from "../sentry";
|
||||
import * as metrics from "../utils/metrics";
|
||||
|
||||
export function createQueue(name: string) {
|
||||
@ -18,6 +19,10 @@ export function createQueue(name: string) {
|
||||
return new Redis(process.env.REDIS_URL);
|
||||
}
|
||||
},
|
||||
defaultJobOptions: {
|
||||
removeOnComplete: true,
|
||||
removeOnFail: true,
|
||||
},
|
||||
});
|
||||
|
||||
queue.on("stalled", () => {
|
||||
@ -28,7 +33,12 @@ export function createQueue(name: string) {
|
||||
metrics.increment(`${prefix}.jobs.completed`);
|
||||
});
|
||||
|
||||
queue.on("error", () => {
|
||||
queue.on("error", (err) => {
|
||||
if (process.env.SENTRY_DSN) {
|
||||
Sentry.captureException(err);
|
||||
} else {
|
||||
console.error(err);
|
||||
}
|
||||
metrics.increment(`${prefix}.jobs.errored`);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user