diff --git a/dev-packages/e2e-tests/test-applications/nestjs-basic/src/schedule.service.ts b/dev-packages/e2e-tests/test-applications/nestjs-basic/src/schedule.service.ts index 38b56136ab20..791d9aa83c20 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-basic/src/schedule.service.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-basic/src/schedule.service.ts @@ -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 diff --git a/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/schedule-instrumentation.test.ts b/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/schedule-instrumentation.test.ts index aa8a90c66cd5..b3f5a416f090 100644 --- a/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/schedule-instrumentation.test.ts +++ b/dev-packages/e2e-tests/test-applications/nestjs-basic/tests/schedule-instrumentation.test.ts @@ -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' ); }); @@ -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' ); });