From 8c9a0cccd1eb03229b9653e38159f62fd3e1e5e3 Mon Sep 17 00:00:00 2001 From: Francesco Gringl-Novy Date: Tue, 5 May 2026 09:43:53 +0200 Subject: [PATCH] test(node): Fix flaky node cron test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes https://github.com/getsentry/sentry-javascript/issues/20652 cron instrumentation used loggingTransport, which console.logs each envelope as JSON. The scenario also console.logs (You will see this message every second). The runner parses envelopes by splitting child stdout on newlines. Under CI load that mix can produce ordering / buffering issues or fragile parsing compared with sending envelopes over HTTP. Fix Align with the pattern used elsewhere (including the ANR fix): scenario.ts — Drop loggingTransport and initialize with dsn: process.env.SENTRY_DSN so the runner-injected URL from the mock ingest server is used. test.ts — Call .withMockSentryServer() so check-ins and the error event are received via the mock HTTP server instead of stdout. --- .../node-core-integration-tests/suites/cron/cron/scenario.ts | 4 +--- .../node-core-integration-tests/suites/cron/cron/test.ts | 1 + .../node-integration-tests/suites/cron/cron/scenario.ts | 4 +--- dev-packages/node-integration-tests/suites/cron/cron/test.ts | 1 + 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/dev-packages/node-core-integration-tests/suites/cron/cron/scenario.ts b/dev-packages/node-core-integration-tests/suites/cron/cron/scenario.ts index 4ddd9f115189..3ef46faa9e90 100644 --- a/dev-packages/node-core-integration-tests/suites/cron/cron/scenario.ts +++ b/dev-packages/node-core-integration-tests/suites/cron/cron/scenario.ts @@ -1,12 +1,10 @@ import * as Sentry from '@sentry/node-core'; -import { loggingTransport } from '@sentry-internal/node-integration-tests'; import { CronJob } from 'cron'; import { setupOtel } from '../../../utils/setupOtel'; const client = Sentry.init({ - dsn: 'https://public@dsn.ingest.sentry.io/1337', + dsn: process.env.SENTRY_DSN, release: '1.0', - transport: loggingTransport, }); setupOtel(client); diff --git a/dev-packages/node-core-integration-tests/suites/cron/cron/test.ts b/dev-packages/node-core-integration-tests/suites/cron/cron/test.ts index 60edd2812b4b..8209e2332042 100644 --- a/dev-packages/node-core-integration-tests/suites/cron/cron/test.ts +++ b/dev-packages/node-core-integration-tests/suites/cron/cron/test.ts @@ -7,6 +7,7 @@ afterAll(() => { test('cron instrumentation', async () => { await createRunner(__dirname, 'scenario.ts') + .withMockSentryServer() .expect({ check_in: { check_in_id: expect.any(String), diff --git a/dev-packages/node-integration-tests/suites/cron/cron/scenario.ts b/dev-packages/node-integration-tests/suites/cron/cron/scenario.ts index 6fe6838844de..a51eab1d8d6f 100644 --- a/dev-packages/node-integration-tests/suites/cron/cron/scenario.ts +++ b/dev-packages/node-integration-tests/suites/cron/cron/scenario.ts @@ -1,11 +1,9 @@ import * as Sentry from '@sentry/node'; -import { loggingTransport } from '@sentry-internal/node-integration-tests'; import { CronJob } from 'cron'; Sentry.init({ - dsn: 'https://public@dsn.ingest.sentry.io/1337', + dsn: process.env.SENTRY_DSN, release: '1.0', - transport: loggingTransport, }); const CronJobWithCheckIn = Sentry.cron.instrumentCron(CronJob, 'my-cron-job'); diff --git a/dev-packages/node-integration-tests/suites/cron/cron/test.ts b/dev-packages/node-integration-tests/suites/cron/cron/test.ts index 078cc0997221..3606b4d02808 100644 --- a/dev-packages/node-integration-tests/suites/cron/cron/test.ts +++ b/dev-packages/node-integration-tests/suites/cron/cron/test.ts @@ -7,6 +7,7 @@ afterAll(() => { test('cron instrumentation', { timeout: 30_000 }, async () => { await createRunner(__dirname, 'scenario.ts') + .withMockSentryServer() .expect({ check_in: { check_in_id: expect.any(String),