Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ export class ScheduleService {
constructor(private schedulerRegistry: SchedulerRegistry) {}

// @Cron error test (auto-instrumentation, no @SentryCron)
// The timestamp keeps the Dedupe integration from dropping the error on repeated ticks.
@Cron('*/5 * * * * *', { name: 'test-schedule-cron-error' })
handleCronError() {
throw new Error('Test error from schedule cron');
throw new Error(`Test error from schedule cron ${Date.now()}`);
}

// @Interval error test
@Interval('test-schedule-interval-error', 2000)
async handleIntervalError() {
throw new Error('Test error from schedule interval');
throw new Error(`Test error from schedule interval ${Date.now()}`);
}

// @Timeout error test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import { expect, test } from '@playwright/test';
import { waitForError, waitForStreamedSpan } from '@sentry-internal/test-utils';

test('Sends exceptions to Sentry on error in @Cron decorated method', async ({ baseURL }) => {
const testStart = Date.now();
const errorEventPromise = waitForError('nestjs-basic', event => {
const thrownAt = event.exception?.values?.[0]?.value?.match(/^Test error from schedule cron (\d+)$/)?.[1];
return (
!event.type &&
event.exception?.values?.[0]?.value === 'Test error from schedule cron' &&
Number(thrownAt) >= testStart &&
event.exception?.values?.[0]?.mechanism?.type === 'auto.function.nestjs.cron'
);
});
Expand All @@ -23,10 +25,12 @@ test('Sends exceptions to Sentry on error in @Cron decorated method', async ({ b
});

test('Sends exceptions to Sentry on error in @Interval decorated method', async ({ baseURL }) => {
const testStart = Date.now();
const errorEventPromise = waitForError('nestjs-basic', event => {
const thrownAt = event.exception?.values?.[0]?.value?.match(/^Test error from schedule interval (\d+)$/)?.[1];
return (
!event.type &&
event.exception?.values?.[0]?.value === 'Test error from schedule interval' &&
Number(thrownAt) >= testStart &&
event.exception?.values?.[0]?.mechanism?.type === 'auto.function.nestjs.interval'
);
});
Expand Down
Loading