Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sentry exception on last retry in jobs resolver #1542

Merged
merged 1 commit into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/utils/worker/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PrismaClient } from '@prisma/client';
import * as Sentry from '@sentry/nextjs';

import { JobDataMap, JobKind, jobKind, jobState } from './create';
import * as resolve from './resolve';
Expand All @@ -20,6 +21,10 @@ console.log('Worker started successfully');
},
});

if (jobs.length > 300) {
Sentry.captureMessage('Queue too long. Smth went wrong.');
awinogradov marked this conversation as resolved.
Show resolved Hide resolved
}

jobs.forEach(async (job) => {
if (job.state === jobState.completed) {
setTimeout(async () => {
Expand All @@ -46,6 +51,15 @@ console.log('Worker started successfully');
data: { state: jobState.scheduled, error: error?.message, retry },
});
}, retry * defaultJobDelay);
} else {
Sentry.captureException(error, {
fingerprint: ['worker', 'resolve', 'retry'],
extra: {
job,
},
});

await prisma.job.delete({ where: { id: job.id } });
}
}
}, job.delay || defaultJobDelay);
Expand Down
Loading