Skip to content

Error thrown in Nest.JS cron job is not being reported in Sentry #14163

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

Closed
3 tasks done
mattpodolak opened this issue Nov 2, 2024 · 3 comments · Fixed by #14182
Closed
3 tasks done

Error thrown in Nest.JS cron job is not being reported in Sentry #14163

mattpodolak opened this issue Nov 2, 2024 · 3 comments · Fixed by #14182
Labels
Package: nestjs Issues related to the Sentry Nestjs SDK

Comments

@mattpodolak
Copy link

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nestjs

SDK Version

8.34.0

Framework Version

10.0.0

Link to Sentry event

No response

Reproduction Example/SDK Setup

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

  1. create a Nest.js project, add the above code, and start the server

Expected Result

the error should appear in Sentry

Actual Result

no error is reported

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Nov 2, 2024
@github-actions github-actions bot added the Package: nestjs Issues related to the Sentry Nestjs SDK label Nov 2, 2024
@andreiborza
Copy link
Member

Hi @mattpodolak, thanks for filing this. We'll take a look.

@andreiborza
Copy link
Member

@mattpodolak thanks again for reporting this. Turns out it affected all our cron monitoring.

This will go out with the next release.

Copy link
Contributor

github-actions bot commented 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: nestjs Issues related to the Sentry Nestjs SDK
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants