You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error thrown in Nest.JS cron job is not being reported in Sentry #14163
import * as Sentry from '@sentry/nestjs';
import { nodeProfilingIntegration } from '@sentry/profiling-node';
Sentry.init({
dsn: __YOUR_DSN__,
integrations: [nodeProfilingIntegration()],
// Tracing
tracesSampleRate: 1.0, // Capture 100% of the transactions
// Set sampling rate for profiling - this is relative to tracesSampleRate
profilesSampleRate: 1.0,
environment: process.env.NODE_ENV ?? 'development',
});
import^ at the top of the main.ts file
create a module that has this service:
import { Cron, CronExpression } from '@nestjs/schedule';
import { Injectable } from '@nestjs/common';
import { SentryTraced } from '@sentry/nestjs';
@Injectable()
export class CronJobs {
@Cron(CronExpression.EVERY_MINUTE, {
name: 'testinCron',
timeZone: 'America/New_York',
})
@SentryTraced()
async testCron() {
throw new Error('Test error');
}
}
Steps to Reproduce
create a Nest.js project, add the above code, and start the server
Activity
andreiborza commentedon Nov 4, 2024
Hi @mattpodolak, thanks for filing this. We'll take a look.
fix(core): Ensure errors thrown in async cron jobs bubble up (#14182)
andreiborza commentedon Nov 5, 2024
@mattpodolak thanks again for reporting this. Turns out it affected all our cron monitoring.
This will go out with the next release.
github-actions commentedon Nov 5, 2024
A PR closing this issue has just been released 🚀
This issue was referenced by PR #14182, which was included in the 8.37.0 release.