diff --git a/dev-packages/cloudflare-integration-tests/runner.ts b/dev-packages/cloudflare-integration-tests/runner.ts index 849b011250f9..8ea63dd8513b 100644 --- a/dev-packages/cloudflare-integration-tests/runner.ts +++ b/dev-packages/cloudflare-integration-tests/runner.ts @@ -54,7 +54,7 @@ type StartResult = { /** Creates a test runner */ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -export function createRunner(...paths: string[]) { +export function createRunner({ signal }: { readonly signal?: AbortSignal }, ...paths: string[]) { const testPath = join(...paths); if (!existsSync(testPath)) { @@ -130,7 +130,7 @@ export function createRunner(...paths: string[]) { } } - createBasicSentryServer(newEnvelope) + createBasicSentryServer(newEnvelope, { signal }) .then(([mockServerPort, mockServerClose]) => { if (mockServerClose) { CLEANUP_STEPS.add(() => { @@ -155,7 +155,7 @@ export function createRunner(...paths: string[]) { '--var', `SENTRY_DSN:http://public@localhost:${mockServerPort}/1337`, ], - { stdio }, + { stdio, signal }, ); CLEANUP_STEPS.add(() => { diff --git a/dev-packages/cloudflare-integration-tests/suites/basic/test.ts b/dev-packages/cloudflare-integration-tests/suites/basic/test.ts index b785e6e37fd1..901327190b03 100644 --- a/dev-packages/cloudflare-integration-tests/suites/basic/test.ts +++ b/dev-packages/cloudflare-integration-tests/suites/basic/test.ts @@ -2,8 +2,8 @@ import { expect, it } from 'vitest'; import { eventEnvelope } from '../../expect'; import { createRunner } from '../../runner'; -it('Basic error in fetch handler', async () => { - const runner = createRunner(__dirname) +it('Basic error in fetch handler', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname) .expect( eventEnvelope({ level: 'error', diff --git a/dev-packages/cloudflare-integration-tests/suites/tracing/anthropic-ai/test.ts b/dev-packages/cloudflare-integration-tests/suites/tracing/anthropic-ai/test.ts index 13966caaf460..ea11cb6c4cf9 100644 --- a/dev-packages/cloudflare-integration-tests/suites/tracing/anthropic-ai/test.ts +++ b/dev-packages/cloudflare-integration-tests/suites/tracing/anthropic-ai/test.ts @@ -6,8 +6,8 @@ import { createRunner } from '../../../runner'; // want to test that the instrumentation does not break in our // cloudflare SDK. -it('traces a basic message creation request', async () => { - const runner = createRunner(__dirname) +it('traces a basic message creation request', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname) .ignore('event') .expect(envelope => { const transactionEvent = envelope[1]?.[0]?.[1] as any; diff --git a/dev-packages/cloudflare-integration-tests/suites/tracing/durableobject/test.ts b/dev-packages/cloudflare-integration-tests/suites/tracing/durableobject/test.ts index a9daae21480f..eb70b13361cd 100644 --- a/dev-packages/cloudflare-integration-tests/suites/tracing/durableobject/test.ts +++ b/dev-packages/cloudflare-integration-tests/suites/tracing/durableobject/test.ts @@ -1,8 +1,8 @@ import { expect, it } from 'vitest'; import { createRunner } from '../../../runner'; -it('traces a durable object method', async () => { - const runner = createRunner(__dirname) +it('traces a durable object method', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname) .expect(envelope => { const transactionEvent = envelope[1]?.[0]?.[1]; expect(transactionEvent).toEqual( diff --git a/dev-packages/cloudflare-integration-tests/suites/tracing/google-genai/test.ts b/dev-packages/cloudflare-integration-tests/suites/tracing/google-genai/test.ts index 3c36e832a17a..8378e610be2d 100644 --- a/dev-packages/cloudflare-integration-tests/suites/tracing/google-genai/test.ts +++ b/dev-packages/cloudflare-integration-tests/suites/tracing/google-genai/test.ts @@ -6,8 +6,8 @@ import { createRunner } from '../../../runner'; // want to test that the instrumentation does not break in our // cloudflare SDK. -it('traces Google GenAI chat creation and message sending', async () => { - const runner = createRunner(__dirname) +it('traces Google GenAI chat creation and message sending', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname) .ignore('event') .expect(envelope => { const transactionEvent = envelope[1]?.[0]?.[1] as any; diff --git a/dev-packages/cloudflare-integration-tests/suites/tracing/openai/test.ts b/dev-packages/cloudflare-integration-tests/suites/tracing/openai/test.ts index c1aee24136a4..e61f6bede00e 100644 --- a/dev-packages/cloudflare-integration-tests/suites/tracing/openai/test.ts +++ b/dev-packages/cloudflare-integration-tests/suites/tracing/openai/test.ts @@ -6,11 +6,11 @@ import { createRunner } from '../../../runner'; // want to test that the instrumentation does not break in our // cloudflare SDK. -it('traces a basic chat completion request', async () => { - const runner = createRunner(__dirname) +it('traces a basic chat completion request', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname) .ignore('event') .expect(envelope => { - const transactionEvent = envelope[1]?.[0]?.[1]; + const transactionEvent = envelope[1]?.[0]?.[1] as any; expect(transactionEvent.transaction).toBe('GET /'); expect(transactionEvent.spans).toEqual( diff --git a/dev-packages/e2e-tests/registrySetup.ts b/dev-packages/e2e-tests/registrySetup.ts index 80cbcd10d384..5b57ab92ed0e 100644 --- a/dev-packages/e2e-tests/registrySetup.ts +++ b/dev-packages/e2e-tests/registrySetup.ts @@ -17,11 +17,15 @@ function groupCIOutput(groupTitle: string, fn: () => void): void { } } -export function registrySetup(): void { +export function registrySetup(signal?: AbortSignal): void { groupCIOutput('Test Registry Setup', () => { // Stop test registry container (Verdaccio) if it was already running - childProcess.spawnSync('docker', ['stop', TEST_REGISTRY_CONTAINER_NAME], { stdio: 'ignore' }); - console.log('Stopped previously running test registry'); + const stop = (): void => { + childProcess.spawnSync('docker', ['stop', TEST_REGISTRY_CONTAINER_NAME], { stdio: 'ignore' }); + console.log('Stopped previously running test registry'); + }; + stop(); + signal?.addEventListener('abort', () => stop()); // Start test registry (Verdaccio) const startRegistryProcessResult = childProcess.spawnSync( @@ -38,7 +42,7 @@ export function registrySetup(): void { `${__dirname}/verdaccio-config:/verdaccio/conf`, `verdaccio/verdaccio:${VERDACCIO_VERSION}`, ], - { encoding: 'utf8', stdio: 'inherit' }, + { encoding: 'utf8', stdio: 'inherit', signal }, ); if (startRegistryProcessResult.status !== 0) { @@ -60,6 +64,7 @@ export function registrySetup(): void { { encoding: 'utf8', stdio: 'inherit', + signal, }, ); @@ -82,6 +87,7 @@ export function registrySetup(): void { { encoding: 'utf8', stdio: 'inherit', + signal, }, ); diff --git a/dev-packages/e2e-tests/run.ts b/dev-packages/e2e-tests/run.ts index cb2685ec0489..0ad36facfc55 100644 --- a/dev-packages/e2e-tests/run.ts +++ b/dev-packages/e2e-tests/run.ts @@ -12,7 +12,10 @@ const DEFAULT_DSN = 'https://username@domain/123'; const DEFAULT_SENTRY_ORG_SLUG = 'sentry-javascript-sdks'; const DEFAULT_SENTRY_PROJECT = 'sentry-javascript-e2e-tests'; -function asyncExec(command: string, options: { env: Record; cwd: string }): Promise { +function asyncExec( + command: string, + options: { env: Record; cwd: string; signal: AbortSignal }, +): Promise { return new Promise((resolve, reject) => { const process = spawn(command, { ...options, shell: true }); @@ -41,6 +44,8 @@ async function run(): Promise { // Load environment variables from .env file locally dotenv.config(); + const abortController = new AbortController(); + // Allow to run a single app only via `yarn test:run ` const appName = process.argv[2] || ''; @@ -65,11 +70,11 @@ async function run(): Promise { console.log(''); if (!process.env.SKIP_REGISTRY) { - registrySetup(); + registrySetup(abortController.signal); } - await asyncExec('pnpm clean:test-applications', { env, cwd: __dirname }); - await asyncExec('pnpm cache delete "@sentry/*"', { env, cwd: __dirname }); + await asyncExec('pnpm clean:test-applications', { env, cwd: __dirname, signal: abortController.signal }); + await asyncExec('pnpm cache delete "@sentry/*"', { env, cwd: __dirname, signal: abortController.signal }); const testAppPaths = appName ? [appName.trim()] : globSync('*', { cwd: `${__dirname}/test-applications/` }); @@ -84,15 +89,17 @@ async function run(): Promise { const cwd = tmpDirPath; console.log(`Building ${testAppPath} in ${tmpDirPath}...`); - await asyncExec('volta run pnpm test:build', { env, cwd }); + await asyncExec('volta run pnpm test:build', { env, cwd, signal: abortController.signal }); console.log(`Testing ${testAppPath}...`); - await asyncExec('volta run pnpm test:assert', { env, cwd }); + await asyncExec('volta run pnpm test:assert', { env, cwd, signal: abortController.signal }); // clean up (although this is tmp, still nice to do) await rm(tmpDirPath, { recursive: true }); } + abortController.abort(); } catch (error) { + abortController.abort(error); console.error(error); process.exit(1); } diff --git a/dev-packages/e2e-tests/test-applications/aws-serverless/src/stack.ts b/dev-packages/e2e-tests/test-applications/aws-serverless/src/stack.ts index d23feae60811..9afc7d376f8c 100644 --- a/dev-packages/e2e-tests/test-applications/aws-serverless/src/stack.ts +++ b/dev-packages/e2e-tests/test-applications/aws-serverless/src/stack.ts @@ -1,10 +1,9 @@ -import { Stack, CfnResource, StackProps } from 'aws-cdk-lib'; +import { CfnResource, Stack, StackProps } from 'aws-cdk-lib'; import { Construct } from 'constructs'; import * as path from 'node:path'; import * as fs from 'node:fs'; import * as os from 'node:os'; import * as dns from 'node:dns/promises'; -import { platform } from 'node:process'; import { globSync } from 'glob'; import { execFileSync } from 'node:child_process'; @@ -123,10 +122,5 @@ export async function getHostIp() { return host.address; } - if (platform === 'darwin' || platform === 'win32') { - return 'host.docker.internal'; - } - - const host = await dns.lookup(os.hostname()); - return host.address; + return 'host.docker.internal'; } diff --git a/dev-packages/e2e-tests/test-applications/aws-serverless/tests/lambda-fixtures.ts b/dev-packages/e2e-tests/test-applications/aws-serverless/tests/lambda-fixtures.ts index d6f331c7e96b..f7d27c5fb329 100644 --- a/dev-packages/e2e-tests/test-applications/aws-serverless/tests/lambda-fixtures.ts +++ b/dev-packages/e2e-tests/test-applications/aws-serverless/tests/lambda-fixtures.ts @@ -5,6 +5,7 @@ import { LocalLambdaStack, SAM_PORT, getHostIp } from '../src/stack'; import { writeFileSync } from 'node:fs'; import { spawn, execSync } from 'node:child_process'; import { LambdaClient } from '@aws-sdk/client-lambda'; +import { platform } from 'node:process'; const DOCKER_NETWORK_NAME = 'lambda-test-network'; const SAM_TEMPLATE_FILE = 'sam.template.yml'; @@ -16,7 +17,7 @@ export const test = base.extend<{ testEnvironment: LocalLambdaStack; lambdaClien async ({}, use) => { console.log('[testEnvironment fixture] Setting up AWS Lambda test infrastructure'); - execSync('docker network prune -f'); + execSync(`docker network rm -f ${DOCKER_NETWORK_NAME} || /bin/true`); execSync(`docker network create --driver bridge ${DOCKER_NETWORK_NAME}`); const hostIp = await getHostIp(); @@ -44,6 +45,10 @@ export const test = base.extend<{ testEnvironment: LocalLambdaStack; lambdaClien '--skip-pull-image', ]; + if ('host.docker.internal' === hostIp && !['darwin', 'windows'].includes(platform)) { + args.push('--add-host', `${hostIp}:host-gateway`); + } + if (process.env.NODE_VERSION) { args.push('--invoke-image', `public.ecr.aws/lambda/nodejs:${process.env.NODE_VERSION}`); } diff --git a/dev-packages/e2e-tests/test-applications/debug-id-sourcemaps/tests/server.test.ts b/dev-packages/e2e-tests/test-applications/debug-id-sourcemaps/tests/server.test.ts index d16e8239990c..413a02691e55 100644 --- a/dev-packages/e2e-tests/test-applications/debug-id-sourcemaps/tests/server.test.ts +++ b/dev-packages/e2e-tests/test-applications/debug-id-sourcemaps/tests/server.test.ts @@ -9,9 +9,13 @@ const EVENT_POLLING_TIMEOUT = 90_000; test( 'Find symbolicated event on sentry', - async ({ expect }) => { + async ({ expect, skip }) => { + if (!authToken) { + skip('Auth token not set, skipping test'); + } const eventId = childProcess.execSync(`node ${path.join(__dirname, '..', 'dist', 'app.js')}`, { encoding: 'utf-8', + timeout: 5_000, }); console.log(`Polling for error eventId: ${eventId}`); diff --git a/dev-packages/node-core-integration-tests/suites/tracing/dsc-txn-name-update/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/dsc-txn-name-update/test.ts index 9fe401badaa7..77c56bd2c170 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/dsc-txn-name-update/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/dsc-txn-name-update/test.ts @@ -6,12 +6,12 @@ import { createTestServer } from '../../../utils/server'; // This test requires Node.js 22+ because it depends on the 'http.client.request.created' // diagnostic channel for baggage header propagation, which only exists since Node 22.12.0+ and 23.2.0+ conditionalTest({ min: 22 })('node >=22', () => { - test('adds current transaction name to baggage when the txn name is high-quality', async () => { + test('adds current transaction name to baggage when the txn name is high-quality', async ({ signal }) => { expect.assertions(5); let traceId: string | undefined; - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', (headers: Record) => { const baggageItems = getBaggageHeaderItems(headers); traceId = baggageItems.find(item => item.startsWith('sentry-trace_id='))?.split('=')[1] as string; @@ -54,7 +54,7 @@ conditionalTest({ min: 22 })('node >=22', () => { }) .start(); - await createRunner(__dirname, 'scenario-headers.ts') + await createRunner({ signal }, __dirname, 'scenario-headers.ts') .withEnv({ SERVER_URL }) .expect({ transaction: {}, @@ -65,10 +65,10 @@ conditionalTest({ min: 22 })('node >=22', () => { }); }); -test('adds current transaction name to trace envelope header when the txn name is high-quality', async () => { +test('adds current transaction name to trace envelope header when the txn name is high-quality', async ({ signal }) => { expect.assertions(4); - await createRunner(__dirname, 'scenario-events.ts') + await createRunner({ signal }, __dirname, 'scenario-events.ts') .expectHeader({ event: { trace: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-breadcrumbs/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-breadcrumbs/test.ts index 0d1d33bb5fc9..282b9161edc3 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-breadcrumbs/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-breadcrumbs/test.ts @@ -6,10 +6,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing fetch', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { conditionalTest({ min: 22 })('node >=22', () => { - test('outgoing fetch requests create breadcrumbs', async () => { - const [SERVER_URL, closeTestServer] = await createTestServer().start(); + test('outgoing fetch requests create breadcrumbs', async ({ signal }) => { + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }).start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing-no-spans/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing-no-spans/test.ts index f61532d9de8b..a92cf6464930 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing-no-spans/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing-no-spans/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing fetch', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing fetch requests are correctly instrumented with tracing & spans are disabled', async () => { + test('outgoing fetch requests are correctly instrumented with tracing & spans are disabled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); @@ -28,7 +28,7 @@ describe('outgoing fetch', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts index b4594c4d9c41..a59376297606 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing fetch', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing fetch requests are correctly instrumented with tracing disabled', async () => { + test('outgoing fetch requests are correctly instrumented with tracing disabled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); @@ -28,7 +28,7 @@ describe('outgoing fetch', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts index 32f24517b3f6..4ed95689f652 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing fetch', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing sampled fetch requests without active span are correctly instrumented', async () => { + test('outgoing sampled fetch requests without active span are correctly instrumented', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); @@ -28,7 +28,7 @@ describe('outgoing fetch', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts index 097236ba4e7f..845a6ef8a940 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing fetch', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing fetch requests are correctly instrumented when not sampled', async () => { + test('outgoing fetch requests are correctly instrumented when not sampled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); @@ -28,7 +28,7 @@ describe('outgoing fetch', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-breadcrumbs/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-breadcrumbs/test.ts index 318d4628453b..198673b792c6 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-breadcrumbs/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-breadcrumbs/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing http requests create breadcrumbs', async () => { - const [SERVER_URL, closeTestServer] = await createTestServer().start(); + test('outgoing http requests create breadcrumbs', async ({ signal }) => { + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }).start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts index fe9cba032344..a7cf583cb11f 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts @@ -6,10 +6,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http requests with tracing & spans disabled', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { conditionalTest({ min: 22 })('node >=22', () => { - test('outgoing http requests are correctly instrumented with tracing & spans disabled', async () => { + test('outgoing http requests are correctly instrumented with tracing & spans disabled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); @@ -30,7 +30,7 @@ describe('outgoing http requests with tracing & spans disabled', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { @@ -104,10 +104,12 @@ describe('outgoing http requests with tracing & spans disabled', () => { // On older node versions, outgoing requests do not get trace-headers injected, sadly // This is because the necessary diagnostics channel hook is not available yet conditionalTest({ max: 21 })('node <22', () => { - test('outgoing http requests generate breadcrumbs correctly with tracing & spans disabled', async () => { + test('outgoing http requests generate breadcrumbs correctly with tracing & spans disabled', async ({ + signal, + }) => { expect.assertions(9); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { // This is not instrumented, sadly expect(headers['baggage']).toBeUndefined(); @@ -128,7 +130,7 @@ describe('outgoing http requests with tracing & spans disabled', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing/test.ts index 8727f1cad0de..299c344aaaf3 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing/test.ts @@ -6,10 +6,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { conditionalTest({ min: 22 })('node >=22', () => { - test('outgoing http requests are correctly instrumented with tracing disabled', async () => { + test('outgoing http requests are correctly instrumented with tracing disabled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); @@ -30,7 +30,7 @@ describe('outgoing http', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts index d89992dd362e..45fb4acd5e0d 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts @@ -6,10 +6,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { conditionalTest({ min: 22 })('node >=22', () => { - test('outgoing sampled http requests without active span are correctly instrumented', async () => { + test('outgoing sampled http requests without active span are correctly instrumented', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); @@ -30,7 +30,7 @@ describe('outgoing http', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled/test.ts index 1189afc502e5..b6ad46903e9a 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled/test.ts @@ -6,10 +6,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { conditionalTest({ min: 22 })('node >=22', () => { - test('outgoing sampled http requests are correctly instrumented', async () => { + test('outgoing sampled http requests are correctly instrumented', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); @@ -30,7 +30,7 @@ describe('outgoing http', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ transaction: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-unsampled/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-unsampled/test.ts index 60d3345dcb51..024e9a6fad4e 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-unsampled/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-unsampled/test.ts @@ -6,10 +6,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { conditionalTest({ min: 22 })('node >=22', () => { - test('outgoing http requests are correctly instrumented when not sampled', async () => { + test('outgoing http requests are correctly instrumented when not sampled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); @@ -30,7 +30,7 @@ describe('outgoing http', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/tracePropagationTargets/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/tracePropagationTargets/test.ts index 8ae06f883b38..dcdc857cd8ef 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/tracePropagationTargets/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/tracePropagationTargets/test.ts @@ -6,10 +6,12 @@ import { createTestServer } from '../../../utils/server'; // This test requires Node.js 22+ because it depends on the 'http.client.request.created' // diagnostic channel for baggage header propagation, which only exists since Node 22.12.0+ and 23.2.0+ conditionalTest({ min: 22 })('node >=22', () => { - test('SentryHttpIntegration should instrument correct requests when tracePropagationTargets option is provided', async () => { + test('SentryHttpIntegration should instrument correct requests when tracePropagationTargets option is provided', async ({ + signal, + }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); @@ -30,7 +32,7 @@ conditionalTest({ min: 22 })('node >=22', () => { }) .start(); - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .withEnv({ SERVER_URL }) .expect({ transaction: { diff --git a/dev-packages/node-core-integration-tests/utils/runner.ts b/dev-packages/node-core-integration-tests/utils/runner.ts index da6184dcbb42..577119d3e2c4 100644 --- a/dev-packages/node-core-integration-tests/utils/runner.ts +++ b/dev-packages/node-core-integration-tests/utils/runner.ts @@ -66,6 +66,11 @@ interface DockerOptions { * The command to run after docker compose is up */ setupCommand?: string; + + /** + * The signal to use to cancel the docker compose process + */ + signal?: AbortSignal; } /** @@ -86,7 +91,8 @@ async function runDockerCompose(options: DockerOptions): Promise { // ensure we're starting fresh close(); - const child = spawn('docker', ['compose', 'up'], { cwd }); + const child = spawn('docker', ['compose', 'up'], { cwd, signal: options.signal }); + options.signal?.addEventListener('abort', () => close()); const timeout = setTimeout(() => { close(); @@ -169,7 +175,7 @@ export function createEsmAndCjsTests( scenarioPath: string, instrumentPath: string, callback: ( - createTestRunner: () => ReturnType, + createTestRunner: (options: { signal?: AbortSignal }) => ReturnType, testFn: typeof test | typeof test.fails, mode: 'esm' | 'cjs', ) => void, @@ -191,7 +197,11 @@ export function createEsmAndCjsTests( describe('esm', () => { const testFn = options?.failsOnEsm ? test.fails : test; - callback(() => createRunner(mjsScenarioPath).withFlags('--import', mjsInstrumentPath), testFn, 'esm'); + callback( + ({ signal }) => createRunner({ signal }, mjsScenarioPath).withFlags('--import', mjsInstrumentPath), + testFn, + 'esm', + ); }); describe('cjs', () => { @@ -215,7 +225,11 @@ export function createEsmAndCjsTests( }); const testFn = options?.failsOnCjs ? test.fails : test; - callback(() => createRunner(cjsScenarioPath).withFlags('--require', cjsInstrumentPath), testFn, 'cjs'); + callback( + ({ signal }) => createRunner({ signal }, cjsScenarioPath).withFlags('--require', cjsInstrumentPath), + testFn, + 'cjs', + ); }); } @@ -227,7 +241,7 @@ function convertEsmFileToCjs(inputPath: string, outputPath: string): void { /** Creates a test runner */ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -export function createRunner(...paths: string[]) { +export function createRunner({ signal }: { readonly signal?: AbortSignal }, ...paths: string[]) { const testPath = join(...paths); if (!existsSync(testPath)) { @@ -297,7 +311,7 @@ export function createRunner(...paths: string[]) { } return this; }, - withDockerCompose: function (options: DockerOptions) { + withDockerCompose: function (options: Omit) { dockerOptions = options; return this; }, @@ -420,11 +434,11 @@ export function createRunner(...paths: string[]) { type DockerStartup = VoidFunction | undefined; const serverStartup: Promise = withSentryServer - ? createBasicSentryServer(newEnvelope) + ? createBasicSentryServer(newEnvelope, { signal }) : Promise.resolve([undefined, undefined]); const dockerStartup: Promise = dockerOptions - ? runDockerCompose(dockerOptions) + ? runDockerCompose({ ...dockerOptions, signal }) : Promise.resolve(undefined); const startup = Promise.all([dockerStartup, serverStartup]); diff --git a/dev-packages/node-core-integration-tests/utils/server.ts b/dev-packages/node-core-integration-tests/utils/server.ts index 92e0477c845c..67d8fedf9362 100644 --- a/dev-packages/node-core-integration-tests/utils/server.ts +++ b/dev-packages/node-core-integration-tests/utils/server.ts @@ -9,7 +9,10 @@ import type { AddressInfo } from 'net'; * This does no checks on the envelope, it just calls the callback if it managed to parse an envelope from the raw POST * body data. */ -export function createBasicSentryServer(onEnvelope: (env: Envelope) => void): Promise<[number, () => void]> { +export function createBasicSentryServer( + onEnvelope: (env: Envelope) => void, + { signal }: { readonly signal?: AbortSignal }, +): Promise<[number, () => void]> { const app = express(); app.use(express.raw({ type: () => true, inflate: true, limit: '100mb' })); @@ -28,6 +31,7 @@ export function createBasicSentryServer(onEnvelope: (env: Envelope) => void): Pr return new Promise(resolve => { const server = app.listen(0, () => { const address = server.address() as AddressInfo; + signal?.addEventListener('abort', () => server.close()); resolve([ address.port, () => { @@ -42,7 +46,7 @@ type HeaderAssertCallback = (headers: Record = []; let error: unknown | undefined; @@ -69,6 +73,7 @@ export function createTestServer() { return new Promise(resolve => { const server = app.listen(0, () => { const address = server.address() as AddressInfo; + signal?.addEventListener('abort', () => server.close()); resolve([ `http://localhost:${address.port}`, () => { diff --git a/dev-packages/node-integration-tests/suites/anr/test.ts b/dev-packages/node-integration-tests/suites/anr/test.ts index 08b6a6571e17..f99d6974984e 100644 --- a/dev-packages/node-integration-tests/suites/anr/test.ts +++ b/dev-packages/node-integration-tests/suites/anr/test.ts @@ -112,23 +112,23 @@ describe('should report ANR when event loop blocked', { timeout: 90_000 }, () => cleanupChildProcesses(); }); - test('CJS', async () => { - await createRunner(__dirname, 'basic.js') + test('CJS', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic.js') .withMockSentryServer() .expect({ event: ANR_EVENT_WITH_DEBUG_META }) .start() .completed(); }); - test('ESM', async () => { - await createRunner(__dirname, 'basic.mjs') + test('ESM', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic.mjs') .withMockSentryServer() .expect({ event: ANR_EVENT_WITH_DEBUG_META }) .start() .completed(); }); - test('Custom appRootPath', async () => { + test('Custom appRootPath', async ({ signal }) => { const ANR_EVENT_WITH_SPECIFIC_DEBUG_META: Event = { ...ANR_EVENT_WITH_SCOPE, debug_meta: { @@ -142,15 +142,15 @@ describe('should report ANR when event loop blocked', { timeout: 90_000 }, () => }, }; - await createRunner(__dirname, 'app-path.mjs') + await createRunner({ signal }, __dirname, 'app-path.mjs') .withMockSentryServer() .expect({ event: ANR_EVENT_WITH_SPECIFIC_DEBUG_META }) .start() .completed(); }); - test('multiple events via maxAnrEvents', async () => { - await createRunner(__dirname, 'basic-multiple.mjs') + test('multiple events via maxAnrEvents', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic-multiple.mjs') .withMockSentryServer() .expect({ event: ANR_EVENT_WITH_DEBUG_META }) .expect({ event: ANR_EVENT_WITH_DEBUG_META }) @@ -158,16 +158,16 @@ describe('should report ANR when event loop blocked', { timeout: 90_000 }, () => .completed(); }); - test('blocked indefinitely', async () => { - await createRunner(__dirname, 'indefinite.mjs') + test('blocked indefinitely', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'indefinite.mjs') .withMockSentryServer() .expect({ event: ANR_EVENT }) .start() .completed(); }); - test("With --inspect the debugger isn't used", async () => { - await createRunner(__dirname, 'basic.mjs') + test("With --inspect the debugger isn't used", async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic.mjs') .withMockSentryServer() .withFlags('--inspect') .expect({ event: ANR_EVENT_WITHOUT_STACKTRACE }) @@ -175,24 +175,24 @@ describe('should report ANR when event loop blocked', { timeout: 90_000 }, () => .completed(); }); - test('should exit', async () => { - const runner = createRunner(__dirname, 'should-exit.js').start(); + test('should exit', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'should-exit.js').start(); await new Promise(resolve => setTimeout(resolve, 5_000)); expect(runner.childHasExited()).toBe(true); }); - test('should exit forced', async () => { - const runner = createRunner(__dirname, 'should-exit-forced.js').start(); + test('should exit forced', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'should-exit-forced.js').start(); await new Promise(resolve => setTimeout(resolve, 5_000)); expect(runner.childHasExited()).toBe(true); }); - test('With session', async () => { - await createRunner(__dirname, 'basic-session.js') + test('With session', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic-session.js') .withMockSentryServer() .unignore('session') .expect({ @@ -209,12 +209,15 @@ describe('should report ANR when event loop blocked', { timeout: 90_000 }, () => .completed(); }); - test('from forked process', async () => { - await createRunner(__dirname, 'forker.js').expect({ event: ANR_EVENT_WITH_SCOPE }).start().completed(); + test('from forked process', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'forker.js').expect({ event: ANR_EVENT_WITH_SCOPE }).start().completed(); }); - test('worker can be stopped and restarted', async () => { - await createRunner(__dirname, 'stop-and-start.js').expect({ event: ANR_EVENT_WITH_SCOPE }).start().completed(); + test('worker can be stopped and restarted', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'stop-and-start.js') + .expect({ event: ANR_EVENT_WITH_SCOPE }) + .start() + .completed(); }); const EXPECTED_ISOLATED_EVENT = { @@ -243,8 +246,8 @@ describe('should report ANR when event loop blocked', { timeout: 90_000 }, () => }, }; - test('fetches correct isolated scope', async () => { - await createRunner(__dirname, 'isolated.mjs') + test('fetches correct isolated scope', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'isolated.mjs') .withMockSentryServer() .expect({ event: EXPECTED_ISOLATED_EVENT }) .start() diff --git a/dev-packages/node-integration-tests/suites/aws-serverless/aws-integration/s3/test.ts b/dev-packages/node-integration-tests/suites/aws-serverless/aws-integration/s3/test.ts index a6fdc2ce88af..afb2c2340058 100644 --- a/dev-packages/node-integration-tests/suites/aws-serverless/aws-integration/s3/test.ts +++ b/dev-packages/node-integration-tests/suites/aws-serverless/aws-integration/s3/test.ts @@ -27,8 +27,8 @@ describe('awsIntegration', () => { cleanupChildProcesses(); }); - test('should auto-instrument aws-sdk v2 package.', async () => { - await createRunner(__dirname, 'scenario.js') + test('should auto-instrument aws-sdk v2 package.', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.js') .ignore('event') .expect({ transaction: EXPECTED_TRANSCATION }) .start() diff --git a/dev-packages/node-integration-tests/suites/aws-serverless/graphql/useOperationNameForRootSpan/test.ts b/dev-packages/node-integration-tests/suites/aws-serverless/graphql/useOperationNameForRootSpan/test.ts index 84098edb46ae..2b6d69fdf403 100644 --- a/dev-packages/node-integration-tests/suites/aws-serverless/graphql/useOperationNameForRootSpan/test.ts +++ b/dev-packages/node-integration-tests/suites/aws-serverless/graphql/useOperationNameForRootSpan/test.ts @@ -17,8 +17,8 @@ describe('graphqlIntegration', () => { cleanupChildProcesses(); }); - test('should use GraphQL operation name for root span if useOperationNameForRootSpan is set', async () => { - await createRunner(__dirname, 'scenario.js') + test('should use GraphQL operation name for root span if useOperationNameForRootSpan is set', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.js') .ignore('event') .expect({ transaction: { transaction: 'Test Server Start (query IntrospectionQuery)' } }) .expect({ transaction: EXPECTED_TRANSCATION }) diff --git a/dev-packages/node-integration-tests/suites/breadcrumbs/process-thread/test.ts b/dev-packages/node-integration-tests/suites/breadcrumbs/process-thread/test.ts index a3ae49da4808..be55e78dc68e 100644 --- a/dev-packages/node-integration-tests/suites/breadcrumbs/process-thread/test.ts +++ b/dev-packages/node-integration-tests/suites/breadcrumbs/process-thread/test.ts @@ -40,8 +40,8 @@ conditionalTest({ min: 20 })('should capture process and thread breadcrumbs', () cleanupChildProcesses(); }); - test('ESM', async () => { - await createRunner(__dirname, 'app.mjs') + test('ESM', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'app.mjs') .withMockSentryServer() .expect({ event: EVENT as Event }) .start() diff --git a/dev-packages/node-integration-tests/suites/child-process/test.ts b/dev-packages/node-integration-tests/suites/child-process/test.ts index 1d04772c351e..22292e9deff1 100644 --- a/dev-packages/node-integration-tests/suites/child-process/test.ts +++ b/dev-packages/node-integration-tests/suites/child-process/test.ts @@ -45,22 +45,22 @@ describe('should capture child process events', () => { }); conditionalTest({ min: 20 })('worker', () => { - test('ESM', async () => { - await createRunner(__dirname, 'worker.mjs').expect({ event: WORKER_EVENT }).start().completed(); + test('ESM', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'worker.mjs').expect({ event: WORKER_EVENT }).start().completed(); }); - test('CJS', async () => { - await createRunner(__dirname, 'worker.js').expect({ event: WORKER_EVENT }).start().completed(); + test('CJS', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'worker.js').expect({ event: WORKER_EVENT }).start().completed(); }); }); conditionalTest({ min: 20 })('fork', () => { - test('ESM', async () => { - await createRunner(__dirname, 'fork.mjs').expect({ event: CHILD_EVENT }).start().completed(); + test('ESM', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'fork.mjs').expect({ event: CHILD_EVENT }).start().completed(); }); - test('CJS', async () => { - await createRunner(__dirname, 'fork.js').expect({ event: CHILD_EVENT }).start().completed(); + test('CJS', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'fork.js').expect({ event: CHILD_EVENT }).start().completed(); }); }); }); diff --git a/dev-packages/node-integration-tests/suites/client-reports/drop-reasons/before-send/test.ts b/dev-packages/node-integration-tests/suites/client-reports/drop-reasons/before-send/test.ts index 73a40fd88d17..ed7f40d0ee6a 100644 --- a/dev-packages/node-integration-tests/suites/client-reports/drop-reasons/before-send/test.ts +++ b/dev-packages/node-integration-tests/suites/client-reports/drop-reasons/before-send/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should record client report for beforeSend', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should record client report for beforeSend', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .unignore('client_report') .expect({ client_report: { diff --git a/dev-packages/node-integration-tests/suites/client-reports/drop-reasons/event-processors/test.ts b/dev-packages/node-integration-tests/suites/client-reports/drop-reasons/event-processors/test.ts index 4e236e375c40..731ee706de2f 100644 --- a/dev-packages/node-integration-tests/suites/client-reports/drop-reasons/event-processors/test.ts +++ b/dev-packages/node-integration-tests/suites/client-reports/drop-reasons/event-processors/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should record client report for event processors', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should record client report for event processors', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .unignore('client_report') .expect({ client_report: { diff --git a/dev-packages/node-integration-tests/suites/client-reports/periodic-send/test.ts b/dev-packages/node-integration-tests/suites/client-reports/periodic-send/test.ts index 69775219b784..f261c81a496b 100644 --- a/dev-packages/node-integration-tests/suites/client-reports/periodic-send/test.ts +++ b/dev-packages/node-integration-tests/suites/client-reports/periodic-send/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should flush client reports automatically after the timeout interval', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should flush client reports automatically after the timeout interval', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .unignore('client_report') .expect({ client_report: { diff --git a/dev-packages/node-integration-tests/suites/consola/test.ts b/dev-packages/node-integration-tests/suites/consola/test.ts index cf396e319c51..63d82f97f9e9 100644 --- a/dev-packages/node-integration-tests/suites/consola/test.ts +++ b/dev-packages/node-integration-tests/suites/consola/test.ts @@ -6,8 +6,8 @@ describe('consola integration', () => { cleanupChildProcesses(); }); - test('should capture consola logs with default levels', async () => { - const runner = createRunner(__dirname, 'subject.ts') + test('should capture consola logs with default levels', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'subject.ts') .expect({ log: { items: [ @@ -70,8 +70,8 @@ describe('consola integration', () => { await runner.completed(); }); - test('should capture different consola log types', async () => { - const runner = createRunner(__dirname, 'subject-types.ts') + test('should capture different consola log types', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'subject-types.ts') .expect({ log: { items: [ @@ -271,8 +271,8 @@ describe('consola integration', () => { await runner.completed(); }); - test('should capture consola logs with arguments formatting', async () => { - const runner = createRunner(__dirname, 'subject-args.ts') + test('should capture consola logs with arguments formatting', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'subject-args.ts') .expect({ log: { items: [ @@ -330,8 +330,8 @@ describe('consola integration', () => { await runner.completed(); }); - test('should capture consola logs with tags', async () => { - const runner = createRunner(__dirname, 'subject-tags.ts') + test('should capture consola logs with tags', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'subject-tags.ts') .expect({ log: { items: [ @@ -379,8 +379,8 @@ describe('consola integration', () => { await runner.completed(); }); - test('should respect custom level filtering', async () => { - const runner = createRunner(__dirname, 'subject-custom-levels.ts') + test('should respect custom level filtering', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'subject-custom-levels.ts') .expect({ log: { items: [ @@ -428,8 +428,8 @@ describe('consola integration', () => { await runner.completed(); }); - test('should capture different consola level methods', async () => { - const runner = createRunner(__dirname, 'subject-levels.ts') + test('should capture different consola level methods', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'subject-levels.ts') .expect({ log: { items: [ diff --git a/dev-packages/node-integration-tests/suites/contextLines/filename-with-spaces/test.ts b/dev-packages/node-integration-tests/suites/contextLines/filename-with-spaces/test.ts index 276e8930b1ea..715eb661231f 100644 --- a/dev-packages/node-integration-tests/suites/contextLines/filename-with-spaces/test.ts +++ b/dev-packages/node-integration-tests/suites/contextLines/filename-with-spaces/test.ts @@ -3,11 +3,11 @@ import { describe, expect, test } from 'vitest'; import { createRunner } from '../../../utils/runner'; describe('ContextLines integration in ESM', () => { - test('reads encoded context lines from filenames with spaces', async () => { + test('reads encoded context lines from filenames with spaces', async ({ signal }) => { expect.assertions(1); const instrumentPath = join(__dirname, 'instrument.mjs'); - await createRunner(__dirname, 'scenario with space.mjs') + await createRunner({ signal }, __dirname, 'scenario with space.mjs') .withInstrument(instrumentPath) .expect({ event: { @@ -41,10 +41,10 @@ describe('ContextLines integration in ESM', () => { }); describe('ContextLines integration in CJS', () => { - test('reads context lines from filenames with spaces', async () => { + test('reads context lines from filenames with spaces', async ({ signal }) => { expect.assertions(1); - await createRunner(__dirname, 'scenario with space.cjs') + await createRunner({ signal }, __dirname, 'scenario with space.cjs') .expect({ event: { exception: { diff --git a/dev-packages/node-integration-tests/suites/contextLines/memory-leak/test.ts b/dev-packages/node-integration-tests/suites/contextLines/memory-leak/test.ts index 1a5170c05fe7..47929563aa7a 100644 --- a/dev-packages/node-integration-tests/suites/contextLines/memory-leak/test.ts +++ b/dev-packages/node-integration-tests/suites/contextLines/memory-leak/test.ts @@ -7,8 +7,8 @@ describe('ContextLines integration in CJS', () => { }); // Regression test for: https://github.com/getsentry/sentry-javascript/issues/14892 - test('does not leak open file handles', async () => { - await createRunner(__dirname, 'scenario.ts') + test('does not leak open file handles', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expectN(10, { event: {}, }) 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 8b9fdfd5c593..206694f3fbb5 100644 --- a/dev-packages/node-integration-tests/suites/cron/cron/test.ts +++ b/dev-packages/node-integration-tests/suites/cron/cron/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('cron instrumentation', async () => { - await createRunner(__dirname, 'scenario.ts') +test('cron instrumentation', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ check_in: { check_in_id: expect.any(String), diff --git a/dev-packages/node-integration-tests/suites/cron/node-cron/test.ts b/dev-packages/node-integration-tests/suites/cron/node-cron/test.ts index 1c5fa515e208..c26e6a30a2f3 100644 --- a/dev-packages/node-integration-tests/suites/cron/node-cron/test.ts +++ b/dev-packages/node-integration-tests/suites/cron/node-cron/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('node-cron instrumentation', async () => { - await createRunner(__dirname, 'scenario.ts') +test('node-cron instrumentation', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ check_in: { check_in_id: expect.any(String), diff --git a/dev-packages/node-integration-tests/suites/cron/node-schedule/test.ts b/dev-packages/node-integration-tests/suites/cron/node-schedule/test.ts index a2019253203f..e827021d8dce 100644 --- a/dev-packages/node-integration-tests/suites/cron/node-schedule/test.ts +++ b/dev-packages/node-integration-tests/suites/cron/node-schedule/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('node-schedule instrumentation', async () => { - await createRunner(__dirname, 'scenario.ts') +test('node-schedule instrumentation', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ check_in: { check_in_id: expect.any(String), diff --git a/dev-packages/node-integration-tests/suites/esm/modules-integration/test.ts b/dev-packages/node-integration-tests/suites/esm/modules-integration/test.ts index 94995aedb91f..3c8beff11eef 100644 --- a/dev-packages/node-integration-tests/suites/esm/modules-integration/test.ts +++ b/dev-packages/node-integration-tests/suites/esm/modules-integration/test.ts @@ -6,7 +6,7 @@ afterAll(() => { }); describe('modulesIntegration', () => { - test('does not crash ESM setups', async () => { - await createRunner(__dirname, 'app.mjs').ensureNoErrorOutput().start().completed(); + test('does not crash ESM setups', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'app.mjs').ensureNoErrorOutput().start().completed(); }); }); diff --git a/dev-packages/node-integration-tests/suites/esm/warn-esm/test.ts b/dev-packages/node-integration-tests/suites/esm/warn-esm/test.ts index 18eebdab6e85..ce984ece650a 100644 --- a/dev-packages/node-integration-tests/suites/esm/warn-esm/test.ts +++ b/dev-packages/node-integration-tests/suites/esm/warn-esm/test.ts @@ -7,34 +7,34 @@ afterAll(() => { const esmWarning = `[Sentry] You are using Node.js v${process.versions.node} in ESM mode ("import syntax"). The Sentry Node.js SDK is not compatible with ESM in Node.js versions before 18.19.0 or before 20.6.0. Please either build your application with CommonJS ("require() syntax"), or upgrade your Node.js version.`; -test("warns if using ESM on Node.js versions that don't support `register()`", async () => { +test("warns if using ESM on Node.js versions that don't support `register()`", async ({ signal }) => { const nodeMajorVersion = Number(process.versions.node.split('.')[0]); if (nodeMajorVersion >= 18) { return; } - const runner = createRunner(__dirname, 'server.mjs').ignore('event').start(); + const runner = createRunner({ signal }, __dirname, 'server.mjs').ignore('event').start(); await runner.makeRequest('get', '/test/success'); expect(runner.getLogs()).toContain(esmWarning); }); -test('does not warn if using ESM on Node.js versions that support `register()`', async () => { +test('does not warn if using ESM on Node.js versions that support `register()`', async ({ signal }) => { const nodeMajorVersion = Number(process.versions.node.split('.')[0]); if (nodeMajorVersion < 18) { return; } - const runner = createRunner(__dirname, 'server.mjs').ignore('event').start(); + const runner = createRunner({ signal }, __dirname, 'server.mjs').ignore('event').start(); await runner.makeRequest('get', '/test/success'); expect(runner.getLogs()).not.toContain(esmWarning); }); -test('does not warn if using CJS', async () => { - const runner = createRunner(__dirname, 'server.js').ignore('event').start(); +test('does not warn if using CJS', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').ignore('event').start(); await runner.makeRequest('get', '/test/success'); diff --git a/dev-packages/node-integration-tests/suites/express/handle-error-scope-data-loss/test.ts b/dev-packages/node-integration-tests/suites/express/handle-error-scope-data-loss/test.ts index cb5d20760c00..315fa7def0bb 100644 --- a/dev-packages/node-integration-tests/suites/express/handle-error-scope-data-loss/test.ts +++ b/dev-packages/node-integration-tests/suites/express/handle-error-scope-data-loss/test.ts @@ -14,8 +14,8 @@ afterAll(() => { * * This test nevertheless covers the behavior so that we're aware. */ -test('withScope scope is NOT applied to thrown error caught by global handler', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('withScope scope is NOT applied to thrown error caught by global handler', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ event: { exception: { @@ -53,8 +53,8 @@ test('withScope scope is NOT applied to thrown error caught by global handler', /** * This test shows that the isolation scope set tags are applied correctly to the error. */ -test('http requestisolation scope is applied to thrown error caught by global handler', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('http requestisolation scope is applied to thrown error caught by global handler', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ event: { exception: { @@ -101,8 +101,8 @@ test('http requestisolation scope is applied to thrown error caught by global ha * a per-request basis, meaning, it's called while we're inside the isolation scope of the http request, * created from our `httpIntegration`. */ -test('withIsolationScope scope is NOT applied to thrown error caught by global handler', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('withIsolationScope scope is NOT applied to thrown error caught by global handler', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ event: { exception: { diff --git a/dev-packages/node-integration-tests/suites/express/handle-error-tracesSampleRate-0/test.ts b/dev-packages/node-integration-tests/suites/express/handle-error-tracesSampleRate-0/test.ts index b8cc2cf53d34..839ee4544f58 100644 --- a/dev-packages/node-integration-tests/suites/express/handle-error-tracesSampleRate-0/test.ts +++ b/dev-packages/node-integration-tests/suites/express/handle-error-tracesSampleRate-0/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should capture and send Express controller error with txn name if tracesSampleRate is 0', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should capture and send Express controller error with txn name if tracesSampleRate is 0', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ event: { exception: { diff --git a/dev-packages/node-integration-tests/suites/express/handle-error-tracesSampleRate-unset/test.ts b/dev-packages/node-integration-tests/suites/express/handle-error-tracesSampleRate-unset/test.ts index a5f9a1332866..5c53131e9efa 100644 --- a/dev-packages/node-integration-tests/suites/express/handle-error-tracesSampleRate-unset/test.ts +++ b/dev-packages/node-integration-tests/suites/express/handle-error-tracesSampleRate-unset/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should capture and send Express controller error if tracesSampleRate is not set.', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should capture and send Express controller error if tracesSampleRate is not set.', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('transaction') .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/express/handle-error/test.ts b/dev-packages/node-integration-tests/suites/express/handle-error/test.ts index 4e702360242f..1a39a4cca7c2 100644 --- a/dev-packages/node-integration-tests/suites/express/handle-error/test.ts +++ b/dev-packages/node-integration-tests/suites/express/handle-error/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should capture and send Express controller error with txn name if tracesSampleRate is 1', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should capture and send Express controller error with txn name if tracesSampleRate is 1', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ transaction: { transaction: 'GET /test/express/:id', diff --git a/dev-packages/node-integration-tests/suites/express/multiple-init/test.ts b/dev-packages/node-integration-tests/suites/express/multiple-init/test.ts index 7ab331485e7d..e9b37d58ba8d 100644 --- a/dev-packages/node-integration-tests/suites/express/multiple-init/test.ts +++ b/dev-packages/node-integration-tests/suites/express/multiple-init/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('allows to call init multiple times', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('allows to call init multiple times', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ event: { exception: { diff --git a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-infix-parameterized/test.ts b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-infix-parameterized/test.ts index 85c3d0a2c353..463689872769 100644 --- a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-infix-parameterized/test.ts +++ b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-infix-parameterized/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should construct correct url with common infixes with multiple parameterized routers.', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should construct correct url with common infixes with multiple parameterized routers.', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('transaction') .expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/user/:userId' } }) .start(); diff --git a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-infix/test.ts b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-infix/test.ts index f6a29574e254..27199debc6ad 100644 --- a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-infix/test.ts +++ b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-infix/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should construct correct url with common infixes with multiple routers.', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should construct correct url with common infixes with multiple routers.', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('transaction') .expect({ event: { message: 'Custom Message', transaction: 'GET /api2/v1/test' } }) .start(); diff --git a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-parameterized-reverse/test.ts b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-parameterized-reverse/test.ts index b2b5baabd103..b74b0a459a7f 100644 --- a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-parameterized-reverse/test.ts +++ b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-parameterized-reverse/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should construct correct urls with multiple parameterized routers (use order reversed).', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should construct correct urls with multiple parameterized routers (use order reversed).', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('transaction') .expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/user/:userId' } }) .start(); diff --git a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-parameterized/test.ts b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-parameterized/test.ts index f362d49ddd03..cab662bd1078 100644 --- a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-parameterized/test.ts +++ b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-parameterized/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should construct correct urls with multiple parameterized routers.', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should construct correct urls with multiple parameterized routers.', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('transaction') .expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/user/:userId' } }) .start(); diff --git a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-same-length-parameterized copy/test.ts b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-same-length-parameterized copy/test.ts index 146e7d0625c5..8ecbcd1ac5eb 100644 --- a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-same-length-parameterized copy/test.ts +++ b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-same-length-parameterized copy/test.ts @@ -5,8 +5,10 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should construct correct url with multiple parameterized routers of the same length (use order reversed).', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should construct correct url with multiple parameterized routers of the same length (use order reversed).', async ({ + signal, +}) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('transaction') .expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/:userId' } }) .start(); diff --git a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-same-length-parameterized/test.ts b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-same-length-parameterized/test.ts index 3209cde3ea23..d2c5f76b9419 100644 --- a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-same-length-parameterized/test.ts +++ b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix-same-length-parameterized/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should construct correct url with multiple parameterized routers of the same length.', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should construct correct url with multiple parameterized routers of the same length.', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('transaction') .expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/:userId' } }) .start(); diff --git a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix/test.ts b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix/test.ts index 12c6584b2d3f..a0e3f9032197 100644 --- a/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix/test.ts +++ b/dev-packages/node-integration-tests/suites/express/multiple-routers/common-prefix/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should construct correct urls with multiple routers.', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should construct correct urls with multiple routers.', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('transaction') .expect({ event: { message: 'Custom Message', transaction: 'GET /api/v1/test' } }) .start(); diff --git a/dev-packages/node-integration-tests/suites/express/multiple-routers/complex-router/test.ts b/dev-packages/node-integration-tests/suites/express/multiple-routers/complex-router/test.ts index fbb97cb6b1df..af0cdb9fed0b 100644 --- a/dev-packages/node-integration-tests/suites/express/multiple-routers/complex-router/test.ts +++ b/dev-packages/node-integration-tests/suites/express/multiple-routers/complex-router/test.ts @@ -6,7 +6,9 @@ afterAll(() => { }); describe('complex-router', () => { - test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route', async () => { + test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route', async ({ + signal, + }) => { const EXPECTED_TRANSACTION = { transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId', transaction_info: { @@ -14,7 +16,7 @@ describe('complex-router', () => { }, }; - const runner = createRunner(__dirname, 'server.ts') + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION as any }) .start(); @@ -22,7 +24,9 @@ describe('complex-router', () => { await runner.completed(); }); - test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route and original url has query params', async () => { + test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route and original url has query params', async ({ + signal, + }) => { const EXPECTED_TRANSACTION = { transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId', transaction_info: { @@ -30,7 +34,7 @@ describe('complex-router', () => { }, }; - const runner = createRunner(__dirname, 'server.ts') + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION as any }) .start(); @@ -38,7 +42,9 @@ describe('complex-router', () => { await runner.completed(); }); - test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route and original url ends with trailing slash and has query params', async () => { + test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route and express used multiple middlewares with route and original url ends with trailing slash and has query params', async ({ + signal, + }) => { const EXPECTED_TRANSACTION = { transaction: 'GET /api/api/v1/sub-router/users/:userId/posts/:postId', transaction_info: { @@ -46,7 +52,7 @@ describe('complex-router', () => { }, }; - const runner = createRunner(__dirname, 'server.ts') + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION as any }) .start(); diff --git a/dev-packages/node-integration-tests/suites/express/multiple-routers/middle-layer-parameterized/test.ts b/dev-packages/node-integration-tests/suites/express/multiple-routers/middle-layer-parameterized/test.ts index 6f24e03bac59..817297984dfe 100644 --- a/dev-packages/node-integration-tests/suites/express/multiple-routers/middle-layer-parameterized/test.ts +++ b/dev-packages/node-integration-tests/suites/express/multiple-routers/middle-layer-parameterized/test.ts @@ -7,7 +7,9 @@ afterAll(() => { // Before Node 16, parametrization is not working properly here describe('middle-layer-parameterized', () => { - test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route', async () => { + test('should construct correct url with multiple parameterized routers, when param is also contain in middle layer route', async ({ + signal, + }) => { const EXPECTED_TRANSACTION = { transaction: 'GET /api/v1/users/:userId/posts/:postId', transaction_info: { @@ -15,7 +17,7 @@ describe('middle-layer-parameterized', () => { }, }; - const runner = createRunner(__dirname, 'server.ts') + const runner = createRunner({ signal }, __dirname, 'server.ts') .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION as any }) .start(); diff --git a/dev-packages/node-integration-tests/suites/express/requestUser/test.ts b/dev-packages/node-integration-tests/suites/express/requestUser/test.ts index 2605b7ed5127..98d54df65a3f 100644 --- a/dev-packages/node-integration-tests/suites/express/requestUser/test.ts +++ b/dev-packages/node-integration-tests/suites/express/requestUser/test.ts @@ -6,10 +6,10 @@ describe('express user handling', () => { cleanupChildProcesses(); }); - test('ignores user from request', async () => { + test('ignores user from request', async ({ signal }) => { expect.assertions(2); - const runner = createRunner(__dirname, 'server.js') + const runner = createRunner({ signal }, __dirname, 'server.js') .expect({ event: event => { expect(event.user).toBeUndefined(); @@ -21,8 +21,8 @@ describe('express user handling', () => { await runner.completed(); }); - test('using setUser in middleware works', async () => { - const runner = createRunner(__dirname, 'server.js') + test('using setUser in middleware works', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .expect({ event: { user: { diff --git a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-assign/test.ts b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-assign/test.ts index 8b8d648513e4..7c9009e79387 100644 --- a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-assign/test.ts +++ b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-assign/test.ts @@ -7,8 +7,10 @@ afterAll(() => { cleanupChildProcesses(); }); -test('Should overwrite baggage if the incoming request already has Sentry baggage data but no sentry-trace', async () => { - const runner = createRunner(__dirname, '..', 'server.ts').start(); +test('Should overwrite baggage if the incoming request already has Sentry baggage data but no sentry-trace', async ({ + signal, +}) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express', { headers: { @@ -25,8 +27,8 @@ test('Should overwrite baggage if the incoming request already has Sentry baggag }); }); -test('Should propagate sentry trace baggage data from an incoming to an outgoing request.', async () => { - const runner = createRunner(__dirname, '..', 'server.ts').start(); +test('Should propagate sentry trace baggage data from an incoming to an outgoing request.', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express', { headers: { @@ -44,8 +46,10 @@ test('Should propagate sentry trace baggage data from an incoming to an outgoing }); }); -test('Should not propagate baggage data from an incoming to an outgoing request if sentry-trace is faulty.', async () => { - const runner = createRunner(__dirname, '..', 'server.ts').start(); +test('Should not propagate baggage data from an incoming to an outgoing request if sentry-trace is faulty.', async ({ + signal, +}) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express', { headers: { @@ -63,8 +67,10 @@ test('Should not propagate baggage data from an incoming to an outgoing request }); }); -test('Should not propagate baggage if sentry-trace header is present in incoming request but no baggage header', async () => { - const runner = createRunner(__dirname, '..', 'server.ts').start(); +test('Should not propagate baggage if sentry-trace header is present in incoming request but no baggage header', async ({ + signal, +}) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express', { headers: { @@ -80,8 +86,10 @@ test('Should not propagate baggage if sentry-trace header is present in incoming }); }); -test('Should not propagate baggage and ignore original 3rd party baggage entries if sentry-trace header is present', async () => { - const runner = createRunner(__dirname, '..', 'server.ts').start(); +test('Should not propagate baggage and ignore original 3rd party baggage entries if sentry-trace header is present', async ({ + signal, +}) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express', { headers: { @@ -98,8 +106,8 @@ test('Should not propagate baggage and ignore original 3rd party baggage entries }); }); -test('Should populate and propagate sentry baggage if sentry-trace header does not exist', async () => { - const runner = createRunner(__dirname, '..', 'server.ts').start(); +test('Should populate and propagate sentry baggage if sentry-trace header does not exist', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express'); @@ -121,8 +129,10 @@ test('Should populate and propagate sentry baggage if sentry-trace header does n }); }); -test('Should populate Sentry and ignore 3rd party content if sentry-trace header does not exist', async () => { - const runner = createRunner(__dirname, '..', 'server.ts').start(); +test('Should populate Sentry and ignore 3rd party content if sentry-trace header does not exist', async ({ + signal, +}) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express', { headers: { diff --git a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/test.ts b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/test.ts index 913fcd5e2038..8aeab47eea5d 100644 --- a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/test.ts +++ b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/test.ts @@ -6,8 +6,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should attach a baggage header to an outgoing request.', async () => { - const runner = createRunner(__dirname, 'server.ts').start(); +test('should attach a baggage header to an outgoing request.', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express'); diff --git a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors-with-sentry-entries/test.ts b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors-with-sentry-entries/test.ts index 2d2074be773c..115707c3daf8 100644 --- a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors-with-sentry-entries/test.ts +++ b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors-with-sentry-entries/test.ts @@ -6,8 +6,10 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should ignore sentry-values in `baggage` header of a third party vendor and overwrite them with incoming DSC', async () => { - const runner = createRunner(__dirname, 'server.ts').start(); +test('should ignore sentry-values in `baggage` header of a third party vendor and overwrite them with incoming DSC', async ({ + signal, +}) => { + const runner = createRunner({ signal }, __dirname, 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express', { headers: { @@ -38,8 +40,10 @@ test('should ignore sentry-values in `baggage` header of a third party vendor an ]); }); -test('should ignore sentry-values in `baggage` header of a third party vendor and overwrite them with new DSC', async () => { - const runner = createRunner(__dirname, 'server.ts').start(); +test('should ignore sentry-values in `baggage` header of a third party vendor and overwrite them with new DSC', async ({ + signal, +}) => { + const runner = createRunner({ signal }, __dirname, 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express'); diff --git a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors/test.ts b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors/test.ts index beb118944408..79dd9005c4ce 100644 --- a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors/test.ts +++ b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors/test.ts @@ -6,8 +6,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should merge `baggage` header of a third party vendor with the Sentry DSC baggage items', async () => { - const runner = createRunner(__dirname, 'server.ts').start(); +test('should merge `baggage` header of a third party vendor with the Sentry DSC baggage items', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express', { headers: { diff --git a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-transaction-name/test.ts b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-transaction-name/test.ts index 436a8ea9b4da..566a3f3c0048 100644 --- a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-transaction-name/test.ts +++ b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-transaction-name/test.ts @@ -6,8 +6,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('Includes transaction in baggage if the transaction name is parameterized', async () => { - const runner = createRunner(__dirname, 'server.ts').start(); +test('Includes transaction in baggage if the transaction name is parameterized', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express'); diff --git a/dev-packages/node-integration-tests/suites/express/sentry-trace/trace-header-assign/test.ts b/dev-packages/node-integration-tests/suites/express/sentry-trace/trace-header-assign/test.ts index 7d0a729dc4ff..211c5729a202 100644 --- a/dev-packages/node-integration-tests/suites/express/sentry-trace/trace-header-assign/test.ts +++ b/dev-packages/node-integration-tests/suites/express/sentry-trace/trace-header-assign/test.ts @@ -7,8 +7,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('Should assign `sentry-trace` header which sets parent trace id of an outgoing request.', async () => { - const runner = createRunner(__dirname, 'server.ts').start(); +test('Should assign `sentry-trace` header which sets parent trace id of an outgoing request.', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express', { headers: { diff --git a/dev-packages/node-integration-tests/suites/express/sentry-trace/trace-header-out/test.ts b/dev-packages/node-integration-tests/suites/express/sentry-trace/trace-header-out/test.ts index 8ed4d08bba55..f9367422dfd0 100644 --- a/dev-packages/node-integration-tests/suites/express/sentry-trace/trace-header-out/test.ts +++ b/dev-packages/node-integration-tests/suites/express/sentry-trace/trace-header-out/test.ts @@ -7,8 +7,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should attach a `sentry-trace` header to an outgoing request.', async () => { - const runner = createRunner(__dirname, '..', 'server.ts').start(); +test('should attach a `sentry-trace` header to an outgoing request.', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express'); diff --git a/dev-packages/node-integration-tests/suites/express/setupExpressErrorHandler/test.ts b/dev-packages/node-integration-tests/suites/express/setupExpressErrorHandler/test.ts index cb76cf3c929b..5907fbcd5db0 100644 --- a/dev-packages/node-integration-tests/suites/express/setupExpressErrorHandler/test.ts +++ b/dev-packages/node-integration-tests/suites/express/setupExpressErrorHandler/test.ts @@ -7,8 +7,8 @@ describe('express setupExpressErrorHandler', () => { }); describe('CJS', () => { - test('allows to pass options to setupExpressErrorHandler', async () => { - const runner = createRunner(__dirname, 'server.js') + test('allows to pass options to setupExpressErrorHandler', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .expect({ event: { exception: { diff --git a/dev-packages/node-integration-tests/suites/express/span-isolationScope/test.ts b/dev-packages/node-integration-tests/suites/express/span-isolationScope/test.ts index f8c7c11378d5..de1fce457013 100644 --- a/dev-packages/node-integration-tests/suites/express/span-isolationScope/test.ts +++ b/dev-packages/node-integration-tests/suites/express/span-isolationScope/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('correctly applies isolation scope to span', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('correctly applies isolation scope to span', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ transaction: { transaction: 'GET /test/isolationScope', diff --git a/dev-packages/node-integration-tests/suites/express/tracing/test.ts b/dev-packages/node-integration-tests/suites/express/tracing/test.ts index 4476c76a3933..c6a1e5015bec 100644 --- a/dev-packages/node-integration-tests/suites/express/tracing/test.ts +++ b/dev-packages/node-integration-tests/suites/express/tracing/test.ts @@ -8,8 +8,8 @@ describe('express tracing', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('should create and send transactions for Express routes and spans for middlewares.', async () => { - const runner = createRunner() + test('should create and send transactions for Express routes and spans for middlewares.', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { contexts: { @@ -51,8 +51,8 @@ describe('express tracing', () => { await runner.completed(); }); - test('should set a correct transaction name for routes specified in RegEx', async () => { - const runner = createRunner() + test('should set a correct transaction name for routes specified in RegEx', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /\\/test\\/regex/', @@ -78,8 +78,8 @@ describe('express tracing', () => { await runner.completed(); }); - test('handles root page correctly', async () => { - const runner = createRunner() + test('handles root page correctly', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /', @@ -106,8 +106,8 @@ describe('express tracing', () => { await runner.completed(); }); - test.each(['/401', '/402', '/403', '/does-not-exist'])('ignores %s route by default', async (url: string) => { - const runner = createRunner() + test.for(['/401', '/402', '/403', '/does-not-exist'])('ignores %s route by default', async (url, { signal }) => { + const runner = createRunner({ signal }) .expect({ // No transaction is sent for the 401, 402, 403, 404 routes transaction: { @@ -120,10 +120,10 @@ describe('express tracing', () => { await runner.completed(); }); - test.each([['array1'], ['array5']])( + test.for(['array1', 'array5'])( 'should set a correct transaction name for routes consisting of arrays of routes for %p', - async (segment: string) => { - const runner = await createRunner() + async (segment, { signal }) => { + const runner = await createRunner({ signal }) .expect({ transaction: { transaction: 'GET /test/array1,/\\/test\\/array[2-9]/', @@ -150,17 +150,17 @@ describe('express tracing', () => { }, ); - test.each([ - ['arr/545'], - ['arr/required'], - ['arr/required'], - ['arr/requiredPath'], - ['arr/required/lastParam'], - ['arr55/required/lastParam'], - ['arr/requiredPath/optionalPath/'], - ['arr/requiredPath/optionalPath/lastParam'], - ])('should handle more complex regexes in route arrays correctly for %p', async (segment: string) => { - const runner = await createRunner() + test.for([ + 'arr/545', + 'arr/required', + 'arr/required', + 'arr/requiredPath', + 'arr/required/lastParam', + 'arr55/required/lastParam', + 'arr/requiredPath/optionalPath/', + 'arr/requiredPath/optionalPath/lastParam', + ])('should handle more complex regexes in route arrays correctly for %p', async (segment, { signal }) => { + const runner = await createRunner({ signal }) .expect({ transaction: { transaction: 'GET /test/arr/:id,/\\/test\\/arr[0-9]*\\/required(path)?(\\/optionalPath)?\\/(lastParam)?/', @@ -187,8 +187,8 @@ describe('express tracing', () => { }); describe('request data', () => { - test('correctly captures JSON request data', async () => { - const runner = createRunner() + test('correctly captures JSON request data', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-post', @@ -217,8 +217,8 @@ describe('express tracing', () => { await runner.completed(); }); - test('correctly captures plain text request data', async () => { - const runner = createRunner() + test('correctly captures plain text request data', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-post', @@ -242,8 +242,8 @@ describe('express tracing', () => { await runner.completed(); }); - test('correctly captures text buffer request data', async () => { - const runner = createRunner() + test('correctly captures text buffer request data', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-post', @@ -267,8 +267,8 @@ describe('express tracing', () => { await runner.completed(); }); - test('correctly captures non-text buffer request data', async () => { - const runner = createRunner() + test('correctly captures non-text buffer request data', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-post', @@ -295,8 +295,8 @@ describe('express tracing', () => { await runner.completed(); }); - test('correctly ignores request data', async () => { - const runner = createRunner() + test('correctly ignores request data', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: e => { assertSentryTransaction(e, { @@ -332,43 +332,40 @@ describe('express tracing', () => { 'instrument-filterStatusCode.mjs', (createRunner, test) => { // We opt-out of the default [401, 404] filtering in order to test how these spans are handled - test.each([ + test.for([ { status_code: 401, url: '/401', status: 'unauthenticated' }, { status_code: 402, url: '/402', status: 'invalid_argument' }, { status_code: 403, url: '/403', status: 'permission_denied' }, { status_code: 404, url: '/does-not-exist', status: 'not_found' }, - ])( - 'handles %s route correctly', - async ({ status_code, url, status }: { status_code: number; url: string; status: string }) => { - const runner = createRunner() - .expect({ - transaction: { - transaction: `GET ${url}`, - contexts: { - trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - data: { - 'http.response.status_code': status_code, - url: expect.stringMatching(url), - 'http.method': 'GET', - 'http.url': expect.stringMatching(url), - 'http.target': url, - }, - op: 'http.server', - status, + ])('handles %s route correctly', async ({ status_code, url, status }, { signal }) => { + const runner = createRunner({ signal }) + .expect({ + transaction: { + transaction: `GET ${url}`, + contexts: { + trace: { + span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f0-9]{32}/), + data: { + 'http.response.status_code': status_code, + url: expect.stringMatching(url), + 'http.method': 'GET', + 'http.url': expect.stringMatching(url), + 'http.target': url, }, + op: 'http.server', + status, }, }, - }) - .start(); - runner.makeRequest('get', url, { expectError: true }); - await runner.completed(); - }, - ); + }, + }) + .start(); + runner.makeRequest('get', url, { expectError: true }); + await runner.completed(); + }); - test('filters defined status codes', async () => { - const runner = createRunner() + test('filters defined status codes', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /', diff --git a/dev-packages/node-integration-tests/suites/express/tracing/tracesSampler/test.ts b/dev-packages/node-integration-tests/suites/express/tracing/tracesSampler/test.ts index 1b644ada387a..243ca398e792 100644 --- a/dev-packages/node-integration-tests/suites/express/tracing/tracesSampler/test.ts +++ b/dev-packages/node-integration-tests/suites/express/tracing/tracesSampler/test.ts @@ -7,8 +7,8 @@ describe('express tracesSampler', () => { }); describe('CJS', () => { - test('correctly samples & passes data to tracesSampler', async () => { - const runner = createRunner(__dirname, 'server.js') + test('correctly samples & passes data to tracesSampler', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .expect({ transaction: { transaction: 'GET /test/:id', @@ -31,8 +31,8 @@ describe('express tracesSampler includes normalizedRequest data', () => { }); describe('CJS', () => { - test('correctly samples & passes data to tracesSampler', async () => { - const runner = createRunner(__dirname, 'scenario-normalizedRequest.js') + test('correctly samples & passes data to tracesSampler', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'scenario-normalizedRequest.js') .expect({ transaction: { transaction: 'GET /test-normalized-request', diff --git a/dev-packages/node-integration-tests/suites/express/tracing/updateName/test.ts b/dev-packages/node-integration-tests/suites/express/tracing/updateName/test.ts index 350ee9714752..994ebf71a097 100644 --- a/dev-packages/node-integration-tests/suites/express/tracing/updateName/test.ts +++ b/dev-packages/node-integration-tests/suites/express/tracing/updateName/test.ts @@ -12,8 +12,10 @@ describe('express tracing', () => { // This test documents the unfortunate behaviour of using `span.updateName` on the server-side. // For http.server root spans (which is the root span on the server 99% of the time), Otel's http instrumentation // calls `span.updateName` and overwrites whatever the name was set to before (by us or by users). - test("calling just `span.updateName` doesn't update the final name in express (missing source)", async () => { - const runner = createRunner(__dirname, 'server.js') + test("calling just `span.updateName` doesn't update the final name in express (missing source)", async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .expect({ transaction: { transaction: 'GET /test/:id/span-updateName', @@ -29,8 +31,10 @@ describe('express tracing', () => { // Also calling `updateName` AND setting a source doesn't change anything - Otel has no concept of source, this is sentry-internal. // Therefore, only the source is updated but the name is still overwritten by Otel. - test('calling `span.updateName` and setting attribute source updates the final name in express', async () => { - const runner = createRunner(__dirname, 'server.js') + test('calling `span.updateName` and setting attribute source updates the final name in express', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .expect({ transaction: { transaction: 'new-name', @@ -45,8 +49,8 @@ describe('express tracing', () => { }); // This test documents the correct way to update the span name (and implicitly the source) in Node: - test('calling `Sentry.updateSpanName` updates the final name and source in express', async () => { - const runner = createRunner(__dirname, 'server.js') + test('calling `Sentry.updateSpanName` updates the final name and source in express', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .expect({ transaction: txnEvent => { expect(txnEvent).toMatchObject({ @@ -72,8 +76,10 @@ describe('express tracing', () => { }); // This test documents the correct way to update the span name (and implicitly the source) in Node: - test('calling `Sentry.updateSpanName` and setting source subsequently updates the final name and sets correct source', async () => { - const runner = createRunner(__dirname, 'server.js') + test('calling `Sentry.updateSpanName` and setting source subsequently updates the final name and sets correct source', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .expect({ transaction: txnEvent => { expect(txnEvent).toMatchObject({ diff --git a/dev-packages/node-integration-tests/suites/express/tracing/withError/test.ts b/dev-packages/node-integration-tests/suites/express/tracing/withError/test.ts index e99c5bf44700..ebfae4384cfc 100644 --- a/dev-packages/node-integration-tests/suites/express/tracing/withError/test.ts +++ b/dev-packages/node-integration-tests/suites/express/tracing/withError/test.ts @@ -7,8 +7,8 @@ describe('express tracing experimental', () => { }); describe('CJS', () => { - test('should apply the scope transactionName to error events', async () => { - const runner = createRunner(__dirname, 'server.js') + test('should apply the scope transactionName to error events', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .ignore('transaction') .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/express/with-http/base/test.ts b/dev-packages/node-integration-tests/suites/express/with-http/base/test.ts index 40c74a3d8888..284a9bf2ff36 100644 --- a/dev-packages/node-integration-tests/suites/express/with-http/base/test.ts +++ b/dev-packages/node-integration-tests/suites/express/with-http/base/test.ts @@ -7,8 +7,8 @@ describe('express with http import', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('it works when importing the http module', async () => { - const runner = createRunner() + test('it works when importing the http module', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /test2', diff --git a/dev-packages/node-integration-tests/suites/express/with-http/maxIncomingRequestBodySize/test.ts b/dev-packages/node-integration-tests/suites/express/with-http/maxIncomingRequestBodySize/test.ts index 5ae6b4e2bacc..4f2527e811d5 100644 --- a/dev-packages/node-integration-tests/suites/express/with-http/maxIncomingRequestBodySize/test.ts +++ b/dev-packages/node-integration-tests/suites/express/with-http/maxIncomingRequestBodySize/test.ts @@ -18,8 +18,8 @@ describe('express with httpIntegration and not defined maxIncomingRequestBodySiz }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument-default.mjs', (createRunner, test) => { - test('captures medium request bodies with default setting (medium)', async () => { - const runner = createRunner() + test('captures medium request bodies with default setting (medium)', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', @@ -38,8 +38,8 @@ describe('express with httpIntegration and not defined maxIncomingRequestBodySiz await runner.completed(); }); - test('truncates large request bodies with default setting (medium)', async () => { - const runner = createRunner() + test('truncates large request bodies with default setting (medium)', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', @@ -70,8 +70,8 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "none"', 'scenario.mjs', 'instrument-none.mjs', (createRunner, test) => { - test('does not capture any request bodies with "none" setting', async () => { - const runner = createRunner() + test('does not capture any request bodies with "none" setting', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', @@ -90,8 +90,10 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "none"', await runner.completed(); }); - test('does not capture any request bodies with "none" setting and "ignoreIncomingRequestBody"', async () => { - const runner = createRunner() + test('does not capture any request bodies with "none" setting and "ignoreIncomingRequestBody"', async ({ + signal, + }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', @@ -137,8 +139,8 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "always"' 'scenario.mjs', 'instrument-always.mjs', (createRunner, test) => { - test('captures maximum allowed request body length with "always" setting', async () => { - const runner = createRunner() + test('captures maximum allowed request body length with "always" setting', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', @@ -157,8 +159,10 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "always"' await runner.completed(); }); - test('captures large request bodies with "always" setting but respects maximum size limit', async () => { - const runner = createRunner() + test('captures large request bodies with "always" setting but respects maximum size limit', async ({ + signal, + }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', @@ -191,8 +195,8 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "small"', 'scenario.mjs', 'instrument-small.mjs', (createRunner, test) => { - test('keeps small request bodies with "small" setting', async () => { - const runner = createRunner() + test('keeps small request bodies with "small" setting', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', @@ -211,8 +215,8 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "small"', await runner.completed(); }); - test('truncates too large request bodies with "small" setting', async () => { - const runner = createRunner() + test('truncates too large request bodies with "small" setting', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', @@ -231,8 +235,8 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "small"', await runner.completed(); }); - test('truncates too large non-ASCII request bodies with "small" setting', async () => { - const runner = createRunner() + test('truncates too large non-ASCII request bodies with "small" setting', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', @@ -266,8 +270,8 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "medium"' 'scenario.mjs', 'instrument-medium.mjs', (createRunner, test) => { - test('keeps medium request bodies with "medium" setting', async () => { - const runner = createRunner() + test('keeps medium request bodies with "medium" setting', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', @@ -286,8 +290,8 @@ describe('express with httpIntegration and maxIncomingRequestBodySize: "medium"' await runner.completed(); }); - test('truncates large request bodies with "medium" setting', async () => { - const runner = createRunner() + test('truncates large request bodies with "medium" setting', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'POST /test-body-size', diff --git a/dev-packages/node-integration-tests/suites/express/without-tracing/test.ts b/dev-packages/node-integration-tests/suites/express/without-tracing/test.ts index 5286ab8d2953..9d2428eef234 100644 --- a/dev-packages/node-integration-tests/suites/express/without-tracing/test.ts +++ b/dev-packages/node-integration-tests/suites/express/without-tracing/test.ts @@ -6,8 +6,8 @@ afterAll(() => { }); describe('express without tracing', () => { - test('correctly applies isolation scope even without tracing', async () => { - const runner = createRunner(__dirname, 'server.ts') + test('correctly applies isolation scope even without tracing', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ event: { transaction: 'GET /test/isolationScope/1', @@ -33,8 +33,8 @@ describe('express without tracing', () => { }); describe('request data', () => { - test('correctly captures JSON request data', async () => { - const runner = createRunner(__dirname, 'server.ts') + test('correctly captures JSON request data', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ event: { transaction: 'POST /test-post', @@ -63,8 +63,8 @@ describe('express without tracing', () => { await runner.completed(); }); - test('correctly captures plain text request data', async () => { - const runner = createRunner(__dirname, 'server.ts') + test('correctly captures plain text request data', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ event: { transaction: 'POST /test-post', @@ -90,8 +90,8 @@ describe('express without tracing', () => { await runner.completed(); }); - test('correctly captures text buffer request data', async () => { - const runner = createRunner(__dirname, 'server.ts') + test('correctly captures text buffer request data', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ event: { transaction: 'POST /test-post', @@ -115,8 +115,8 @@ describe('express without tracing', () => { await runner.completed(); }); - test('correctly captures non-text buffer request data', async () => { - const runner = createRunner(__dirname, 'server.ts') + test('correctly captures non-text buffer request data', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ event: { transaction: 'POST /test-post', diff --git a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/basic/test.ts b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/basic/test.ts index 74ff1c125b45..42056d0553af 100644 --- a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/basic/test.ts +++ b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/basic/test.ts @@ -6,7 +6,7 @@ afterAll(() => { cleanupChildProcesses(); }); -test('Flags captured on error with eviction, update, and no async tasks', async () => { +test('Flags captured on error with eviction, update, and no async tasks', async ({ signal }) => { // Based on scenario.ts. const expectedFlags = [{ flag: 'feat2', result: false }]; for (let i = 4; i <= FLAG_BUFFER_SIZE; i++) { @@ -15,7 +15,7 @@ test('Flags captured on error with eviction, update, and no async tasks', async expectedFlags.push({ flag: `feat${FLAG_BUFFER_SIZE + 1}`, result: true }); expectedFlags.push({ flag: 'feat3', result: true }); - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { exception: { values: [{ type: 'Error', value: 'Test error' }] }, diff --git a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/test.ts b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/test.ts index 947b299923e7..70ade7cce2e7 100644 --- a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/test.ts +++ b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onError/withScope/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('Flags captured on error are isolated by current scope', async () => { - await createRunner(__dirname, 'scenario.ts') +test('Flags captured on error are isolated by current scope', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { exception: { values: [{ type: 'Error', value: 'Error in forked scope' }] }, diff --git a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onSpan/test.ts b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onSpan/test.ts index 4a417a3c3959..74af1d735c66 100644 --- a/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onSpan/test.ts +++ b/dev-packages/node-integration-tests/suites/featureFlags/featureFlagsIntegration/onSpan/test.ts @@ -6,14 +6,14 @@ afterAll(() => { cleanupChildProcesses(); }); -test('Flags captured on span attributes with max limit', async () => { +test('Flags captured on span attributes with max limit', async ({ signal }) => { // Based on scenario.ts. const expectedFlags: Record = {}; for (let i = 1; i <= MAX_FLAGS_PER_SPAN; i++) { expectedFlags[`flag.evaluation.feat${i}`] = i === 3; } - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: { spans: [ diff --git a/dev-packages/node-integration-tests/suites/fs-instrumentation/test.ts b/dev-packages/node-integration-tests/suites/fs-instrumentation/test.ts index 721c569231a0..1ea4cac30f60 100644 --- a/dev-packages/node-integration-tests/suites/fs-instrumentation/test.ts +++ b/dev-packages/node-integration-tests/suites/fs-instrumentation/test.ts @@ -6,8 +6,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should create spans for fs operations that take target argument', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should create spans for fs operations that take target argument', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ transaction: { transaction: 'GET /readFile-error', @@ -33,8 +33,8 @@ test('should create spans for fs operations that take target argument', async () await runner.completed(); }); -test('should create spans for fs operations that take one path', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should create spans for fs operations that take one path', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ transaction: { transaction: 'GET /readFile', @@ -79,8 +79,8 @@ test('should create spans for fs operations that take one path', async () => { await runner.completed(); }); -test('should create spans for fs operations that take src and dest arguments', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should create spans for fs operations that take src and dest arguments', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ transaction: { transaction: 'GET /copyFile', @@ -128,8 +128,8 @@ test('should create spans for fs operations that take src and dest arguments', a await runner.completed(); }); -test('should create spans for fs operations that take existing path and new path arguments', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should create spans for fs operations that take existing path and new path arguments', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ transaction: { transaction: 'GET /link', @@ -177,8 +177,8 @@ test('should create spans for fs operations that take existing path and new path await runner.completed(); }); -test('should create spans for fs operations that take prefix argument', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should create spans for fs operations that take prefix argument', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ transaction: { transaction: 'GET /mkdtemp', @@ -223,8 +223,8 @@ test('should create spans for fs operations that take prefix argument', async () await runner.completed(); }); -test('should create spans for fs operations that take target argument', async () => { - const runner = createRunner(__dirname, 'server.ts') +test('should create spans for fs operations that take target argument', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts') .expect({ transaction: { transaction: 'GET /symlink', diff --git a/dev-packages/node-integration-tests/suites/modules/test.ts b/dev-packages/node-integration-tests/suites/modules/test.ts index 89fe98c62867..f5c8bec0fa28 100644 --- a/dev-packages/node-integration-tests/suites/modules/test.ts +++ b/dev-packages/node-integration-tests/suites/modules/test.ts @@ -8,8 +8,8 @@ describe('modulesIntegration', () => { cleanupChildProcesses(); }); - test('CJS', async () => { - const runner = createRunner(__dirname, 'server.js') + test('CJS', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .withMockSentryServer() .expect({ event: { @@ -27,8 +27,8 @@ describe('modulesIntegration', () => { await runner.completed(); }); - test('ESM', async () => { - const runner = createRunner(__dirname, 'server.mjs') + test('ESM', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.mjs') .withInstrument(join(__dirname, 'instrument.mjs')) .withMockSentryServer() .expect({ diff --git a/dev-packages/node-integration-tests/suites/no-code/test.ts b/dev-packages/node-integration-tests/suites/no-code/test.ts index dfe58ff03f72..6b513d2b256a 100644 --- a/dev-packages/node-integration-tests/suites/no-code/test.ts +++ b/dev-packages/node-integration-tests/suites/no-code/test.ts @@ -17,8 +17,8 @@ describe('no-code init', () => { cleanupChildProcesses(); }); - test('CJS', async () => { - await createRunner(__dirname, 'app.js') + test('CJS', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'app.js') .withFlags('--require=@sentry/node/init') .withMockSentryServer() .expect({ event: EVENT }) @@ -27,8 +27,8 @@ describe('no-code init', () => { }); describe('--import', () => { - test('ESM', async () => { - await createRunner(__dirname, 'app.mjs') + test('ESM', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'app.mjs') .withFlags('--import=@sentry/node/init') .withMockSentryServer() .expect({ event: EVENT }) diff --git a/dev-packages/node-integration-tests/suites/pino/test.ts b/dev-packages/node-integration-tests/suites/pino/test.ts index 15a9397ebb27..47c5d341e17d 100644 --- a/dev-packages/node-integration-tests/suites/pino/test.ts +++ b/dev-packages/node-integration-tests/suites/pino/test.ts @@ -4,10 +4,10 @@ import { conditionalTest } from '../../utils'; import { createRunner } from '../../utils/runner'; conditionalTest({ min: 20 })('Pino integration', () => { - test('has different trace ids for logs from different spans', async () => { + test('has different trace ids for logs from different spans', async ({ signal }) => { const instrumentPath = join(__dirname, 'instrument.mjs'); - await createRunner(__dirname, 'scenario.mjs') + await createRunner({ signal }, __dirname, 'scenario.mjs') .withMockSentryServer() .withInstrument(instrumentPath) .ignore('event') @@ -22,10 +22,10 @@ conditionalTest({ min: 20 })('Pino integration', () => { .completed(); }); - test('captures event and logs', async () => { + test('captures event and logs', async ({ signal }) => { const instrumentPath = join(__dirname, 'instrument.mjs'); - await createRunner(__dirname, 'scenario.mjs') + await createRunner({ signal }, __dirname, 'scenario.mjs') .withMockSentryServer() .withInstrument(instrumentPath) .expect({ @@ -96,10 +96,10 @@ conditionalTest({ min: 20 })('Pino integration', () => { .completed(); }); - test('captures with Pino integrated channel', async () => { + test('captures with Pino integrated channel', async ({ signal }) => { const instrumentPath = join(__dirname, 'instrument.mjs'); - await createRunner(__dirname, 'scenario-next.mjs') + await createRunner({ signal }, __dirname, 'scenario-next.mjs') .withMockSentryServer() .withInstrument(instrumentPath) .expect({ diff --git a/dev-packages/node-integration-tests/suites/proxy/test.ts b/dev-packages/node-integration-tests/suites/proxy/test.ts index 805b913d4814..d53c0ada4497 100644 --- a/dev-packages/node-integration-tests/suites/proxy/test.ts +++ b/dev-packages/node-integration-tests/suites/proxy/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('proxies sentry requests', async () => { - await createRunner(__dirname, 'basic.js') +test('proxies sentry requests', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic.js') .withMockSentryServer() .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts index 2c87d14c2b45..6f6191464835 100644 --- a/dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/LocalVariables/test.ts @@ -43,8 +43,8 @@ describe('LocalVariables integration', () => { cleanupChildProcesses(); }); - test('Should not include local variables by default', async () => { - await createRunner(__dirname, 'no-local-variables.js') + test('Should not include local variables by default', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'no-local-variables.js') .expect({ event: event => { for (const frame of event.exception?.values?.[0]?.stacktrace?.frames || []) { @@ -56,54 +56,54 @@ describe('LocalVariables integration', () => { .completed(); }); - test('Should include local variables when enabled', async () => { - await createRunner(__dirname, 'local-variables.js') + test('Should include local variables when enabled', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'local-variables.js') .expect({ event: EXPECTED_LOCAL_VARIABLES_EVENT }) .start() .completed(); }); - test('Should include local variables when instrumenting via --require', async () => { + test('Should include local variables when instrumenting via --require', async ({ signal }) => { const requirePath = path.resolve(__dirname, 'local-variables-instrument.js'); - await createRunner(__dirname, 'local-variables-no-sentry.js') + await createRunner({ signal }, __dirname, 'local-variables-no-sentry.js') .withFlags(`--require=${requirePath}`) .expect({ event: EXPECTED_LOCAL_VARIABLES_EVENT }) .start() .completed(); }); - test('Should include local variables with ESM', async () => { - await createRunner(__dirname, 'local-variables-caught.mjs') + test('Should include local variables with ESM', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'local-variables-caught.mjs') .expect({ event: EXPECTED_LOCAL_VARIABLES_EVENT }) .start() .completed(); }); conditionalTest({ min: 19 })('Node v19+', () => { - test('Should not import inspector when not in use', async () => { - await createRunner(__dirname, 'deny-inspector.mjs').ensureNoErrorOutput().start().completed(); + test('Should not import inspector when not in use', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'deny-inspector.mjs').ensureNoErrorOutput().start().completed(); }); }); conditionalTest({ min: 20 })('Node v20+', () => { - test('Should retain original local variables when error is re-thrown', async () => { - await createRunner(__dirname, 'local-variables-rethrow.js') + test('Should retain original local variables when error is re-thrown', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'local-variables-rethrow.js') .expect({ event: EXPECTED_LOCAL_VARIABLES_EVENT }) .start() .completed(); }); }); - test('Includes local variables for caught exceptions when enabled', async () => { - await createRunner(__dirname, 'local-variables-caught.js') + test('Includes local variables for caught exceptions when enabled', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'local-variables-caught.js') .expect({ event: EXPECTED_LOCAL_VARIABLES_EVENT }) .start() .completed(); }); - test('Should handle different function name formats', async () => { - await createRunner(__dirname, 'local-variables-name-matching.js') + test('Should handle different function name formats', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'local-variables-name-matching.js') .expect({ event: { exception: { diff --git a/dev-packages/node-integration-tests/suites/public-api/OnUncaughtException/test.ts b/dev-packages/node-integration-tests/suites/public-api/OnUncaughtException/test.ts index 5a35991bfd4b..2d4ae45f0a99 100644 --- a/dev-packages/node-integration-tests/suites/public-api/OnUncaughtException/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/OnUncaughtException/test.ts @@ -76,8 +76,8 @@ describe('OnUncaughtException integration', () => { })); }); - test('sets correct event mechanism', async () => { - await createRunner(__dirname, 'basic.js') + test('sets correct event mechanism', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic.js') .expect({ event: { level: 'fatal', diff --git a/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/empty-obj/test.ts b/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/empty-obj/test.ts index c4f5145a8bbf..04a814ac6c68 100644 --- a/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/empty-obj/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/empty-obj/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should add an empty breadcrumb, when an empty object is given', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should add an empty breadcrumb, when an empty object is given', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'test-empty-obj', diff --git a/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/multiple_breadcrumbs/test.ts b/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/multiple_breadcrumbs/test.ts index 13dba000a823..dbf0ace4f3bc 100644 --- a/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/multiple_breadcrumbs/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/multiple_breadcrumbs/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should add multiple breadcrumbs', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should add multiple breadcrumbs', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'test_multi_breadcrumbs', diff --git a/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/simple_breadcrumb/test.ts b/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/simple_breadcrumb/test.ts index 9708e00201ae..9a416d9e3908 100644 --- a/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/simple_breadcrumb/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/addBreadcrumb/simple_breadcrumb/test.ts @@ -1,8 +1,8 @@ import { test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; -test('should add a simple breadcrumb', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should add a simple breadcrumb', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'test_simple', diff --git a/dev-packages/node-integration-tests/suites/public-api/captureException/catched-error/test.ts b/dev-packages/node-integration-tests/suites/public-api/captureException/catched-error/test.ts index f78c53d5da8c..a52d094ec6ff 100644 --- a/dev-packages/node-integration-tests/suites/public-api/captureException/catched-error/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/captureException/catched-error/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should work inside catch block', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should work inside catch block', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { exception: { diff --git a/dev-packages/node-integration-tests/suites/public-api/captureException/empty-obj/test.ts b/dev-packages/node-integration-tests/suites/public-api/captureException/empty-obj/test.ts index b8a6fe4f85e2..3aa788e4302e 100644 --- a/dev-packages/node-integration-tests/suites/public-api/captureException/empty-obj/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/captureException/empty-obj/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should capture an empty object', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should capture an empty object', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { exception: { diff --git a/dev-packages/node-integration-tests/suites/public-api/captureException/simple-error/test.ts b/dev-packages/node-integration-tests/suites/public-api/captureException/simple-error/test.ts index 3afe450398e3..16ed85cba01c 100644 --- a/dev-packages/node-integration-tests/suites/public-api/captureException/simple-error/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/captureException/simple-error/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should capture a simple error with message', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should capture a simple error with message', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { exception: { diff --git a/dev-packages/node-integration-tests/suites/public-api/captureMessage/parameterized_message/test.ts b/dev-packages/node-integration-tests/suites/public-api/captureMessage/parameterized_message/test.ts index 15e6e76306fe..1243cad59a16 100644 --- a/dev-packages/node-integration-tests/suites/public-api/captureMessage/parameterized_message/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/captureMessage/parameterized_message/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should capture a parameterized representation of the message', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should capture a parameterized representation of the message', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { logentry: { diff --git a/dev-packages/node-integration-tests/suites/public-api/captureMessage/simple_message/test.ts b/dev-packages/node-integration-tests/suites/public-api/captureMessage/simple_message/test.ts index e32081747f28..29473f8e7454 100644 --- a/dev-packages/node-integration-tests/suites/public-api/captureMessage/simple_message/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/captureMessage/simple_message/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should capture a simple message string', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should capture a simple message string', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'Message', diff --git a/dev-packages/node-integration-tests/suites/public-api/captureMessage/simple_message_attachStackTrace/test.ts b/dev-packages/node-integration-tests/suites/public-api/captureMessage/simple_message_attachStackTrace/test.ts index 8c79687b2bc4..a746a4bf9b30 100644 --- a/dev-packages/node-integration-tests/suites/public-api/captureMessage/simple_message_attachStackTrace/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/captureMessage/simple_message_attachStackTrace/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('capture a simple message string with a stack trace if `attachStackTrace` is `true`', async () => { - await createRunner(__dirname, 'scenario.ts') +test('capture a simple message string with a stack trace if `attachStackTrace` is `true`', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'Message', diff --git a/dev-packages/node-integration-tests/suites/public-api/captureMessage/with_level/test.ts b/dev-packages/node-integration-tests/suites/public-api/captureMessage/with_level/test.ts index a44af6931d1f..4d1eb236b357 100644 --- a/dev-packages/node-integration-tests/suites/public-api/captureMessage/with_level/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/captureMessage/with_level/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should capture with different severity levels', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should capture with different severity levels', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'debug_message', level: 'debug' } }) .expect({ event: { message: 'info_message', level: 'info' } }) .expect({ event: { message: 'warning_message', level: 'warning' } }) diff --git a/dev-packages/node-integration-tests/suites/public-api/configureScope/clear_scope/test.ts b/dev-packages/node-integration-tests/suites/public-api/configureScope/clear_scope/test.ts index 19f16417bb50..97f631522811 100644 --- a/dev-packages/node-integration-tests/suites/public-api/configureScope/clear_scope/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/configureScope/clear_scope/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should clear previously set properties of a scope', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should clear previously set properties of a scope', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'cleared_scope', diff --git a/dev-packages/node-integration-tests/suites/public-api/configureScope/set_properties/test.ts b/dev-packages/node-integration-tests/suites/public-api/configureScope/set_properties/test.ts index ecfb83c3a4a3..67031f878e06 100644 --- a/dev-packages/node-integration-tests/suites/public-api/configureScope/set_properties/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/configureScope/set_properties/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should set different properties of a scope', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should set different properties of a scope', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'configured_scope', diff --git a/dev-packages/node-integration-tests/suites/public-api/onUnhandledRejectionIntegration/test.ts b/dev-packages/node-integration-tests/suites/public-api/onUnhandledRejectionIntegration/test.ts index cd0627664ea3..7a380d58c3da 100644 --- a/dev-packages/node-integration-tests/suites/public-api/onUnhandledRejectionIntegration/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/onUnhandledRejectionIntegration/test.ts @@ -73,8 +73,8 @@ test rejection`); }); })); - test('captures exceptions for unhandled rejections', async () => { - await createRunner(__dirname, 'scenario-warn.ts') + test('captures exceptions for unhandled rejections', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario-warn.ts') .expect({ event: { level: 'error', @@ -99,8 +99,8 @@ test rejection`); .completed(); }); - test('captures exceptions for unhandled rejections in strict mode', async () => { - await createRunner(__dirname, 'scenario-strict.ts') + test('captures exceptions for unhandled rejections in strict mode', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario-strict.ts') .expect({ event: { level: 'fatal', @@ -125,11 +125,11 @@ test rejection`); .completed(); }); - test('handles unhandled rejection in spans', async () => { + test('handles unhandled rejection in spans', async ({ signal }) => { let transactionEvent: Event | undefined; let errorEvent: Event | undefined; - await createRunner(__dirname, 'scenario-with-span.ts') + await createRunner({ signal }, __dirname, 'scenario-with-span.ts') .expect({ transaction: transaction => { transactionEvent = transaction; @@ -152,11 +152,11 @@ test rejection`); expect(transactionEvent!.contexts!.trace!.span_id).toBe(errorEvent!.contexts!.trace!.span_id); }); - test('handles unhandled rejection in spans that are ended early', async () => { + test('handles unhandled rejection in spans that are ended early', async ({ signal }) => { let transactionEvent: Event | undefined; let errorEvent: Event | undefined; - await createRunner(__dirname, 'scenario-with-span-ended.ts') + await createRunner({ signal }, __dirname, 'scenario-with-span-ended.ts') .expect({ transaction: transaction => { transactionEvent = transaction; diff --git a/dev-packages/node-integration-tests/suites/public-api/scopes/initialScopes/test.ts b/dev-packages/node-integration-tests/suites/public-api/scopes/initialScopes/test.ts index 8f16958cc1c9..088fc8ada967 100644 --- a/dev-packages/node-integration-tests/suites/public-api/scopes/initialScopes/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/scopes/initialScopes/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should apply scopes correctly', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should apply scopes correctly', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'outer_before', diff --git a/dev-packages/node-integration-tests/suites/public-api/scopes/isolationScope/test.ts b/dev-packages/node-integration-tests/suites/public-api/scopes/isolationScope/test.ts index eb926423ef58..4d07780f108b 100644 --- a/dev-packages/node-integration-tests/suites/public-api/scopes/isolationScope/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/scopes/isolationScope/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should apply scopes correctly', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should apply scopes correctly', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'outer_before', diff --git a/dev-packages/node-integration-tests/suites/public-api/setContext/multiple-contexts/test.ts b/dev-packages/node-integration-tests/suites/public-api/setContext/multiple-contexts/test.ts index 1cf8342e2f29..d764689e6f83 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setContext/multiple-contexts/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setContext/multiple-contexts/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should record multiple contexts', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should record multiple contexts', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'multiple_contexts', diff --git a/dev-packages/node-integration-tests/suites/public-api/setContext/non-serializable-context/test.ts b/dev-packages/node-integration-tests/suites/public-api/setContext/non-serializable-context/test.ts index 34c962e5e216..1f86603fc202 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setContext/non-serializable-context/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setContext/non-serializable-context/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should normalize non-serializable context', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should normalize non-serializable context', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'non_serializable', contexts: {} } }) .start() .completed(); diff --git a/dev-packages/node-integration-tests/suites/public-api/setContext/simple-context/test.ts b/dev-packages/node-integration-tests/suites/public-api/setContext/simple-context/test.ts index 3c28a109130b..7ed60522cad9 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setContext/simple-context/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setContext/simple-context/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should set a simple context', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should set a simple context', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'simple_context_object', diff --git a/dev-packages/node-integration-tests/suites/public-api/setExtra/multiple-extras/test.ts b/dev-packages/node-integration-tests/suites/public-api/setExtra/multiple-extras/test.ts index f40d56af6579..23cc042174f1 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setExtra/multiple-extras/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setExtra/multiple-extras/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should record multiple extras of different types', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should record multiple extras of different types', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'multiple_extras', diff --git a/dev-packages/node-integration-tests/suites/public-api/setExtra/non-serializable-extra/test.ts b/dev-packages/node-integration-tests/suites/public-api/setExtra/non-serializable-extra/test.ts index 113c99883f32..cf081c3c020c 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setExtra/non-serializable-extra/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setExtra/non-serializable-extra/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should normalize non-serializable extra', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should normalize non-serializable extra', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'non_serializable', diff --git a/dev-packages/node-integration-tests/suites/public-api/setExtra/simple-extra/test.ts b/dev-packages/node-integration-tests/suites/public-api/setExtra/simple-extra/test.ts index 115d4ca064a4..33fefae86e0b 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setExtra/simple-extra/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setExtra/simple-extra/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should set a simple extra', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should set a simple extra', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'simple_extra', diff --git a/dev-packages/node-integration-tests/suites/public-api/setExtras/consecutive-calls/test.ts b/dev-packages/node-integration-tests/suites/public-api/setExtras/consecutive-calls/test.ts index da5dc31e9fea..f760c4f7e26d 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setExtras/consecutive-calls/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setExtras/consecutive-calls/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should set extras from multiple consecutive calls', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should set extras from multiple consecutive calls', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'consecutive_calls', diff --git a/dev-packages/node-integration-tests/suites/public-api/setExtras/multiple-extras/test.ts b/dev-packages/node-integration-tests/suites/public-api/setExtras/multiple-extras/test.ts index 614a157fed14..282ca42642bd 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setExtras/multiple-extras/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setExtras/multiple-extras/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should record an extras object', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should record an extras object', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'multiple_extras', diff --git a/dev-packages/node-integration-tests/suites/public-api/setMeasurement/test.ts b/dev-packages/node-integration-tests/suites/public-api/setMeasurement/test.ts index 829e6a7ed3da..a8e6b714387b 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setMeasurement/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setMeasurement/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should attach measurement to transaction', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should attach measurement to transaction', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: { transaction: 'some_transaction', diff --git a/dev-packages/node-integration-tests/suites/public-api/setTag/with-primitives/test.ts b/dev-packages/node-integration-tests/suites/public-api/setTag/with-primitives/test.ts index 23e22402c666..7b96f4822894 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setTag/with-primitives/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setTag/with-primitives/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should set primitive tags', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should set primitive tags', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'primitive_tags', diff --git a/dev-packages/node-integration-tests/suites/public-api/setTags/with-primitives/test.ts b/dev-packages/node-integration-tests/suites/public-api/setTags/with-primitives/test.ts index 23e22402c666..7b96f4822894 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setTags/with-primitives/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setTags/with-primitives/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should set primitive tags', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should set primitive tags', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'primitive_tags', diff --git a/dev-packages/node-integration-tests/suites/public-api/setUser/unset_user/test.ts b/dev-packages/node-integration-tests/suites/public-api/setUser/unset_user/test.ts index 9b7f3e2c23be..e69dab91d175 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setUser/unset_user/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setUser/unset_user/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should unset user', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should unset user', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'no_user' } }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/public-api/setUser/update_user/test.ts b/dev-packages/node-integration-tests/suites/public-api/setUser/update_user/test.ts index 7a6c89f4c213..f9cc21ce6706 100644 --- a/dev-packages/node-integration-tests/suites/public-api/setUser/update_user/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/setUser/update_user/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should update user', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should update user', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'first_user', diff --git a/dev-packages/node-integration-tests/suites/public-api/startSpan/basic-usage/test.ts b/dev-packages/node-integration-tests/suites/public-api/startSpan/basic-usage/test.ts index ea02312afd43..3f116662157f 100644 --- a/dev-packages/node-integration-tests/suites/public-api/startSpan/basic-usage/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/startSpan/basic-usage/test.ts @@ -6,8 +6,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('sends a manually started root span with source custom', async () => { - await createRunner(__dirname, 'scenario.ts') +test('sends a manually started root span with source custom', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: { transaction: 'test_span', @@ -25,8 +25,10 @@ test('sends a manually started root span with source custom', async () => { .completed(); }); -test("doesn't change the name for manually started spans even if attributes triggering inference are set", async () => { - await createRunner(__dirname, 'scenario.ts') +test("doesn't change the name for manually started spans even if attributes triggering inference are set", async ({ + signal, +}) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: { transaction: 'test_span', diff --git a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-root-spans/test.ts b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-root-spans/test.ts index e1b8f793d9b6..ec76a1f66e6d 100644 --- a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-root-spans/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-root-spans/test.ts @@ -5,10 +5,10 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should send manually started parallel root spans in root context', async () => { +test('should send manually started parallel root spans in root context', async ({ signal }) => { expect.assertions(7); - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: { transaction: 'test_span_1' } }) .expect({ transaction: transaction => { diff --git a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/test.ts b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/test.ts index e10a1210a0c9..91cefc4089e1 100644 --- a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope-with-parentSpanId/test.ts @@ -5,8 +5,10 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should send manually started parallel root spans outside of root context with parentSpanId', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should send manually started parallel root spans outside of root context with parentSpanId', async ({ + signal, +}) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: { transaction: 'test_span_1' } }) .expect({ transaction: transaction => { diff --git a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope/test.ts b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope/test.ts index 69fc2bc2774a..6bdbc2eec982 100644 --- a/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/startSpan/parallel-spans-in-scope/test.ts @@ -5,10 +5,10 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should send manually started parallel root spans outside of root context', async () => { +test('should send manually started parallel root spans outside of root context', async ({ signal }) => { expect.assertions(6); - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: { transaction: 'test_span_1' } }) .expect({ transaction: transaction => { diff --git a/dev-packages/node-integration-tests/suites/public-api/startSpan/updateName-method/test.ts b/dev-packages/node-integration-tests/suites/public-api/startSpan/updateName-method/test.ts index c46efa9a7fc3..e91ed1d47a1e 100644 --- a/dev-packages/node-integration-tests/suites/public-api/startSpan/updateName-method/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/startSpan/updateName-method/test.ts @@ -6,8 +6,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('updates the span name when calling `span.updateName`', async () => { - createRunner(__dirname, 'scenario.ts') +test('updates the span name when calling `span.updateName`', async ({ signal }) => { + createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: { transaction: 'new name', diff --git a/dev-packages/node-integration-tests/suites/public-api/startSpan/updateSpanName-function/test.ts b/dev-packages/node-integration-tests/suites/public-api/startSpan/updateSpanName-function/test.ts index 49149d0ed7ec..c475777e0f3c 100644 --- a/dev-packages/node-integration-tests/suites/public-api/startSpan/updateSpanName-function/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/startSpan/updateSpanName-function/test.ts @@ -6,8 +6,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('updates the span name and source when calling `updateSpanName`', async () => { - await createRunner(__dirname, 'scenario.ts') +test('updates the span name and source when calling `updateSpanName`', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: { transaction: 'new name', diff --git a/dev-packages/node-integration-tests/suites/public-api/startSpan/with-nested-spans/test.ts b/dev-packages/node-integration-tests/suites/public-api/startSpan/with-nested-spans/test.ts index c01b837db5f7..ba6cc76a71bf 100644 --- a/dev-packages/node-integration-tests/suites/public-api/startSpan/with-nested-spans/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/startSpan/with-nested-spans/test.ts @@ -7,8 +7,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should report finished spans as children of the root transaction.', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should report finished spans as children of the root transaction.', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: transaction => { const rootSpanId = transaction.contexts?.trace?.span_id; diff --git a/dev-packages/node-integration-tests/suites/public-api/withScope/nested-scopes/test.ts b/dev-packages/node-integration-tests/suites/public-api/withScope/nested-scopes/test.ts index 4e646a233443..2bf22f1ce3b3 100644 --- a/dev-packages/node-integration-tests/suites/public-api/withScope/nested-scopes/test.ts +++ b/dev-packages/node-integration-tests/suites/public-api/withScope/nested-scopes/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should allow nested scoping', async () => { - await createRunner(__dirname, 'scenario.ts') +test('should allow nested scoping', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ event: { message: 'root_before', diff --git a/dev-packages/node-integration-tests/suites/sessions/crashed-session-aggregate/test.ts b/dev-packages/node-integration-tests/suites/sessions/crashed-session-aggregate/test.ts index 712eeffcdeb3..1f789055ae53 100644 --- a/dev-packages/node-integration-tests/suites/sessions/crashed-session-aggregate/test.ts +++ b/dev-packages/node-integration-tests/suites/sessions/crashed-session-aggregate/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should aggregate successful and crashed sessions', async () => { - const runner = createRunner(__dirname, '..', 'server.ts') +test('should aggregate successful and crashed sessions', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts') .ignore('transaction', 'event') .unignore('sessions') .expect({ diff --git a/dev-packages/node-integration-tests/suites/sessions/errored-session-aggregate/test.ts b/dev-packages/node-integration-tests/suites/sessions/errored-session-aggregate/test.ts index 4f35e6259697..80612bb5b7c3 100644 --- a/dev-packages/node-integration-tests/suites/sessions/errored-session-aggregate/test.ts +++ b/dev-packages/node-integration-tests/suites/sessions/errored-session-aggregate/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should aggregate successful, crashed and erroneous sessions', async () => { - const runner = createRunner(__dirname, '..', 'server.ts') +test('should aggregate successful, crashed and erroneous sessions', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts') .ignore('transaction', 'event') .unignore('sessions') .expect({ diff --git a/dev-packages/node-integration-tests/suites/sessions/exited-session-aggregate/test.ts b/dev-packages/node-integration-tests/suites/sessions/exited-session-aggregate/test.ts index 228ee9a98643..887bd5a24053 100644 --- a/dev-packages/node-integration-tests/suites/sessions/exited-session-aggregate/test.ts +++ b/dev-packages/node-integration-tests/suites/sessions/exited-session-aggregate/test.ts @@ -5,8 +5,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should aggregate successful sessions', async () => { - const runner = createRunner(__dirname, '..', 'server.ts') +test('should aggregate successful sessions', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, '..', 'server.ts') .ignore('transaction', 'event') .unignore('sessions') .expect({ diff --git a/dev-packages/node-integration-tests/suites/thread-blocked-native/test.ts b/dev-packages/node-integration-tests/suites/thread-blocked-native/test.ts index d168b8ce75d5..f398479e4c96 100644 --- a/dev-packages/node-integration-tests/suites/thread-blocked-native/test.ts +++ b/dev-packages/node-integration-tests/suites/thread-blocked-native/test.ts @@ -85,23 +85,23 @@ describe('Thread Blocked Native', { timeout: 30_000 }, () => { cleanupChildProcesses(); }); - test('CJS', async () => { - await createRunner(__dirname, 'basic.js') + test('CJS', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic.js') .withMockSentryServer() .expect({ event: ANR_EVENT_WITH_DEBUG_META('basic') }) .start() .completed(); }); - test('ESM', async () => { - await createRunner(__dirname, 'basic.mjs') + test('ESM', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic.mjs') .withMockSentryServer() .expect({ event: ANR_EVENT_WITH_DEBUG_META('basic') }) .start() .completed(); }); - test('Custom appRootPath', async () => { + test('Custom appRootPath', async ({ signal }) => { const ANR_EVENT_WITH_SPECIFIC_DEBUG_META: Event = { ...ANR_EVENT, debug_meta: { @@ -115,15 +115,15 @@ describe('Thread Blocked Native', { timeout: 30_000 }, () => { }, }; - await createRunner(__dirname, 'app-path.mjs') + await createRunner({ signal }, __dirname, 'app-path.mjs') .withMockSentryServer() .expect({ event: ANR_EVENT_WITH_SPECIFIC_DEBUG_META }) .start() .completed(); }); - test('multiple events via maxEventsPerHour', async () => { - await createRunner(__dirname, 'basic-multiple.mjs') + test('multiple events via maxEventsPerHour', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic-multiple.mjs') .withMockSentryServer() .expect({ event: ANR_EVENT_WITH_DEBUG_META('basic-multiple') }) .expect({ event: ANR_EVENT_WITH_DEBUG_META('basic-multiple') }) @@ -131,32 +131,32 @@ describe('Thread Blocked Native', { timeout: 30_000 }, () => { .completed(); }); - test('blocked indefinitely', async () => { - await createRunner(__dirname, 'indefinite.mjs') + test('blocked indefinitely', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'indefinite.mjs') .withMockSentryServer() .expect({ event: ANR_EVENT }) .start() .completed(); }); - test('should exit', async () => { - const runner = createRunner(__dirname, 'should-exit.js').start(); + test('should exit', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'should-exit.js').start(); await new Promise(resolve => setTimeout(resolve, 5_000)); expect(runner.childHasExited()).toBe(true); }); - test('should exit forced', async () => { - const runner = createRunner(__dirname, 'should-exit-forced.js').start(); + test('should exit forced', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'should-exit-forced.js').start(); await new Promise(resolve => setTimeout(resolve, 5_000)); expect(runner.childHasExited()).toBe(true); }); - test('can be disabled with disableBlockDetectionForCallback', async () => { - await createRunner(__dirname, 'basic-disabled.mjs') + test('can be disabled with disableBlockDetectionForCallback', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'basic-disabled.mjs') .withMockSentryServer() .expect({ event: { @@ -168,9 +168,9 @@ describe('Thread Blocked Native', { timeout: 30_000 }, () => { .completed(); }); - test('worker thread', async () => { + test('worker thread', async ({ signal }) => { const instrument = join(__dirname, 'instrument.mjs'); - await createRunner(__dirname, 'worker-main.mjs') + await createRunner({ signal }, __dirname, 'worker-main.mjs') .withMockSentryServer() .withFlags('--import', instrument) .expect({ diff --git a/dev-packages/node-integration-tests/suites/tracing/amqplib/test.ts b/dev-packages/node-integration-tests/suites/tracing/amqplib/test.ts index 0be272187f3f..0bed94b9dd20 100644 --- a/dev-packages/node-integration-tests/suites/tracing/amqplib/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/amqplib/test.ts @@ -30,8 +30,8 @@ describe('amqplib auto-instrumentation', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createTestRunner, test) => { - test('should be able to send and receive messages', { timeout: 60_000 }, async () => { - await createTestRunner() + test('should be able to send and receive messages', { timeout: 60_000 }, async ({ signal }) => { + await createTestRunner({ signal }) .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['Time to start RabbitMQ'], diff --git a/dev-packages/node-integration-tests/suites/tracing/anthropic/test.ts b/dev-packages/node-integration-tests/suites/tracing/anthropic/test.ts index c05db16fc251..e26bca3a6e0e 100644 --- a/dev-packages/node-integration-tests/suites/tracing/anthropic/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/anthropic/test.ts @@ -229,8 +229,8 @@ describe('Anthropic integration', () => { }; createEsmAndCjsTests(__dirname, 'scenario-manual-client.mjs', 'instrument.mjs', (createRunner, test) => { - test('creates anthropic related spans when manually insturmenting client', async () => { - await createRunner() + test('creates anthropic related spans when manually insturmenting client', async ({ signal }) => { + await createRunner({ signal }) .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }) .start() @@ -239,8 +239,8 @@ describe('Anthropic integration', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('creates anthropic related spans with sendDefaultPii: false', async () => { - await createRunner() + test('creates anthropic related spans with sendDefaultPii: false', async ({ signal }) => { + await createRunner({ signal }) .expect({ event: EXPECTED_MODEL_ERROR }) .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }) .expect({ event: EXPECTED_STREAM_EVENT_HANDLER_MESSAGE }) @@ -250,8 +250,8 @@ describe('Anthropic integration', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('creates anthropic related spans with sendDefaultPii: true', async () => { - await createRunner() + test('creates anthropic related spans with sendDefaultPii: true', async ({ signal }) => { + await createRunner({ signal }) .expect({ event: EXPECTED_MODEL_ERROR }) .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_TRUE }) .expect({ event: EXPECTED_STREAM_EVENT_HANDLER_MESSAGE }) @@ -261,8 +261,8 @@ describe('Anthropic integration', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument-with-options.mjs', (createRunner, test) => { - test('creates anthropic related spans with custom options', async () => { - await createRunner() + test('creates anthropic related spans with custom options', async ({ signal }) => { + await createRunner({ signal }) .expect({ event: EXPECTED_MODEL_ERROR }) .expect({ transaction: EXPECTED_TRANSACTION_WITH_OPTIONS }) .expect({ event: EXPECTED_STREAM_EVENT_HANDLER_MESSAGE }) @@ -335,25 +335,33 @@ describe('Anthropic integration', () => { }; createEsmAndCjsTests(__dirname, 'scenario-stream.mjs', 'instrument.mjs', (createRunner, test) => { - test('streams produce spans with token usage and metadata (PII false)', async () => { - await createRunner().ignore('event').expect({ transaction: EXPECTED_STREAM_SPANS_PII_FALSE }).start().completed(); + test('streams produce spans with token usage and metadata (PII false)', async ({ signal }) => { + await createRunner({ signal }) + .ignore('event') + .expect({ transaction: EXPECTED_STREAM_SPANS_PII_FALSE }) + .start() + .completed(); }); }); createEsmAndCjsTests(__dirname, 'scenario-stream.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('streams record response text when PII true', async () => { - await createRunner().ignore('event').expect({ transaction: EXPECTED_STREAM_SPANS_PII_TRUE }).start().completed(); + test('streams record response text when PII true', async ({ signal }) => { + await createRunner({ signal }) + .ignore('event') + .expect({ transaction: EXPECTED_STREAM_SPANS_PII_TRUE }) + .start() + .completed(); }); }); // Non-streaming tool calls + available tools (PII true) createEsmAndCjsTests(__dirname, 'scenario-tools.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('non-streaming sets available tools and tool calls with PII', async () => { + test('non-streaming sets available tools and tool calls with PII', async ({ signal }) => { const EXPECTED_TOOLS_JSON = '[{"name":"weather","description":"Get the weather by city","input_schema":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}]'; const EXPECTED_TOOL_CALLS_JSON = '[{"type":"tool_use","id":"tool_weather_1","name":"weather","input":{"city":"Paris"}}]'; - await createRunner() + await createRunner({ signal }) .ignore('event') .expect({ transaction: { @@ -375,12 +383,12 @@ describe('Anthropic integration', () => { // Streaming tool calls + available tools (PII true) createEsmAndCjsTests(__dirname, 'scenario-stream-tools.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('streaming sets available tools and tool calls with PII', async () => { + test('streaming sets available tools and tool calls with PII', async ({ signal }) => { const EXPECTED_TOOLS_JSON = '[{"name":"weather","description":"Get weather","input_schema":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}]'; const EXPECTED_TOOL_CALLS_JSON = '[{"type":"tool_use","id":"tool_weather_2","name":"weather","input":{"city":"Paris"}}]'; - await createRunner() + await createRunner({ signal }) .ignore('event') .expect({ transaction: { @@ -452,8 +460,12 @@ describe('Anthropic integration', () => { }; createEsmAndCjsTests(__dirname, 'scenario-stream-errors.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('handles streaming errors correctly', async () => { - await createRunner().ignore('event').expect({ transaction: EXPECTED_STREAM_ERROR_SPANS }).start().completed(); + test('handles streaming errors correctly', async ({ signal }) => { + await createRunner({ signal }) + .ignore('event') + .expect({ transaction: EXPECTED_STREAM_ERROR_SPANS }) + .start() + .completed(); }); }); @@ -493,8 +505,8 @@ describe('Anthropic integration', () => { }; createEsmAndCjsTests(__dirname, 'scenario-errors.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('handles tool errors and model retrieval errors correctly', async () => { - await createRunner().ignore('event').expect({ transaction: EXPECTED_ERROR_SPANS }).start().completed(); + test('handles tool errors and model retrieval errors correctly', async ({ signal }) => { + await createRunner({ signal }).ignore('event').expect({ transaction: EXPECTED_ERROR_SPANS }).start().completed(); }); }); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/apollo-graphql/test.ts b/dev-packages/node-integration-tests/suites/tracing/apollo-graphql/test.ts index 4d6661101dc0..f8afbdd16c7e 100644 --- a/dev-packages/node-integration-tests/suites/tracing/apollo-graphql/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/apollo-graphql/test.ts @@ -7,7 +7,7 @@ const EXPECTED_START_SERVER_TRANSACTION = { }; describe('GraphQL/Apollo Tests', () => { - test('should instrument GraphQL queries used from Apollo Server.', async () => { + test('should instrument GraphQL queries used from Apollo Server.', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction (query)', spans: expect.arrayContaining([ @@ -24,14 +24,14 @@ describe('GraphQL/Apollo Tests', () => { ]), }; - await createRunner(__dirname, 'scenario-query.js') + await createRunner({ signal }, __dirname, 'scenario-query.js') .expect({ transaction: EXPECTED_START_SERVER_TRANSACTION }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('should instrument GraphQL mutations used from Apollo Server.', async () => { + test('should instrument GraphQL mutations used from Apollo Server.', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction (mutation Mutation)', spans: expect.arrayContaining([ @@ -49,14 +49,14 @@ describe('GraphQL/Apollo Tests', () => { ]), }; - await createRunner(__dirname, 'scenario-mutation.js') + await createRunner({ signal }, __dirname, 'scenario-mutation.js') .expect({ transaction: EXPECTED_START_SERVER_TRANSACTION }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('should handle GraphQL errors.', async () => { + test('should handle GraphQL errors.', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction (mutation Mutation)', spans: expect.arrayContaining([ @@ -74,7 +74,7 @@ describe('GraphQL/Apollo Tests', () => { ]), }; - await createRunner(__dirname, 'scenario-error.js') + await createRunner({ signal }, __dirname, 'scenario-error.js') .expect({ transaction: EXPECTED_START_SERVER_TRANSACTION }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() diff --git a/dev-packages/node-integration-tests/suites/tracing/apollo-graphql/useOperationNameForRootSpan/test.ts b/dev-packages/node-integration-tests/suites/tracing/apollo-graphql/useOperationNameForRootSpan/test.ts index a2b9492e87a1..9b52a4a22a85 100644 --- a/dev-packages/node-integration-tests/suites/tracing/apollo-graphql/useOperationNameForRootSpan/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/apollo-graphql/useOperationNameForRootSpan/test.ts @@ -7,7 +7,7 @@ const EXPECTED_START_SERVER_TRANSACTION = { }; describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => { - test('useOperationNameForRootSpan works with single query operation', async () => { + test('useOperationNameForRootSpan works with single query operation', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'GET /test-graphql (query GetHello)', spans: expect.arrayContaining([ @@ -25,14 +25,14 @@ describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => { ]), }; - await createRunner(__dirname, 'scenario-query.js') + await createRunner({ signal }, __dirname, 'scenario-query.js') .expect({ transaction: EXPECTED_START_SERVER_TRANSACTION }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('useOperationNameForRootSpan works with single mutation operation', async () => { + test('useOperationNameForRootSpan works with single mutation operation', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'GET /test-graphql (mutation TestMutation)', spans: expect.arrayContaining([ @@ -52,14 +52,14 @@ describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => { ]), }; - await createRunner(__dirname, 'scenario-mutation.js') + await createRunner({ signal }, __dirname, 'scenario-mutation.js') .expect({ transaction: EXPECTED_START_SERVER_TRANSACTION }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('useOperationNameForRootSpan ignores an invalid root span', async () => { + test('useOperationNameForRootSpan ignores an invalid root span', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'test span name (query GetHello)', spans: expect.arrayContaining([ @@ -77,14 +77,14 @@ describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => { ]), }; - await createRunner(__dirname, 'scenario-invalid-root-span.js') + await createRunner({ signal }, __dirname, 'scenario-invalid-root-span.js') .expect({ transaction: EXPECTED_START_SERVER_TRANSACTION }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('useOperationNameForRootSpan works with single query operation without name', async () => { + test('useOperationNameForRootSpan works with single query operation without name', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'GET /test-graphql (query)', spans: expect.arrayContaining([ @@ -101,14 +101,14 @@ describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => { ]), }; - await createRunner(__dirname, 'scenario-no-operation-name.js') + await createRunner({ signal }, __dirname, 'scenario-no-operation-name.js') .expect({ transaction: EXPECTED_START_SERVER_TRANSACTION }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('useOperationNameForRootSpan works with multiple query operations', async () => { + test('useOperationNameForRootSpan works with multiple query operations', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'GET /test-graphql (query GetHello, query GetWorld)', spans: expect.arrayContaining([ @@ -137,20 +137,20 @@ describe('GraphQL/Apollo Tests > useOperationNameForRootSpan', () => { ]), }; - await createRunner(__dirname, 'scenario-multiple-operations.js') + await createRunner({ signal }, __dirname, 'scenario-multiple-operations.js') .expect({ transaction: EXPECTED_START_SERVER_TRANSACTION }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('useOperationNameForRootSpan works with more than 5 query operations', async () => { + test('useOperationNameForRootSpan works with more than 5 query operations', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'GET /test-graphql (query GetHello1, query GetHello2, query GetHello3, query GetHello4, query GetHello5, +4)', }; - await createRunner(__dirname, 'scenario-multiple-operations-many.js') + await createRunner({ signal }, __dirname, 'scenario-multiple-operations-many.js') .expect({ transaction: EXPECTED_START_SERVER_TRANSACTION }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() diff --git a/dev-packages/node-integration-tests/suites/tracing/connect/test.ts b/dev-packages/node-integration-tests/suites/tracing/connect/test.ts index 0c37c58f8a4c..2c4f3851d704 100644 --- a/dev-packages/node-integration-tests/suites/tracing/connect/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/connect/test.ts @@ -41,20 +41,20 @@ describe('connect auto-instrumentation', () => { 'scenario.mjs', 'instrument.mjs', (createTestRunner, test) => { - test('should auto-instrument `connect` package.', async () => { - const runner = createTestRunner().expect({ transaction: EXPECTED_TRANSACTION }).start(); + test('should auto-instrument `connect` package.', async ({ signal }) => { + const runner = createTestRunner({ signal }).expect({ transaction: EXPECTED_TRANSACTION }).start(); runner.makeRequest('get', '/'); await runner.completed(); }); - test('should capture errors in `connect` middleware.', async () => { - const runner = createTestRunner().ignore('transaction').expect({ event: EXPECTED_EVENT }).start(); + test('should capture errors in `connect` middleware.', async ({ signal }) => { + const runner = createTestRunner({ signal }).ignore('transaction').expect({ event: EXPECTED_EVENT }).start(); runner.makeRequest('get', '/error'); await runner.completed(); }); - test('should report errored transactions.', async () => { - const runner = createTestRunner() + test('should report errored transactions.', async ({ signal }) => { + const runner = createTestRunner({ signal }) .ignore('event') .expect({ transaction: { transaction: 'GET /error' } }) .start(); diff --git a/dev-packages/node-integration-tests/suites/tracing/dataloader/test.ts b/dev-packages/node-integration-tests/suites/tracing/dataloader/test.ts index 5bfb6ff72a39..0166b066f008 100644 --- a/dev-packages/node-integration-tests/suites/tracing/dataloader/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/dataloader/test.ts @@ -33,8 +33,8 @@ describe('dataloader auto-instrumentation', () => { }; createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('should auto-instrument `dataloader` package.', async () => { - const runner = createRunner().expect({ transaction: EXPECTED_TRANSACTION }).start(); + test('should auto-instrument `dataloader` package.', async ({ signal }) => { + const runner = createRunner({ signal }).expect({ transaction: EXPECTED_TRANSACTION }).start(); runner.makeRequest('get', '/'); await runner.completed(); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/dsc-txn-name-update/test.ts b/dev-packages/node-integration-tests/suites/tracing/dsc-txn-name-update/test.ts index f450d2150e31..60ea999c5007 100644 --- a/dev-packages/node-integration-tests/suites/tracing/dsc-txn-name-update/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/dsc-txn-name-update/test.ts @@ -2,12 +2,12 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../utils/runner'; import { createTestServer } from '../../../utils/server'; -test('adds current transaction name to baggage when the txn name is high-quality', async () => { +test('adds current transaction name to baggage when the txn name is high-quality', async ({ signal }) => { expect.assertions(5); let traceId: string | undefined; - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { const baggageItems = getBaggageHeaderItems(headers); traceId = baggageItems.find(item => item.startsWith('sentry-trace_id='))?.split('=')[1] as string; @@ -50,7 +50,7 @@ test('adds current transaction name to baggage when the txn name is high-quality }) .start(); - await createRunner(__dirname, 'scenario-headers.ts') + await createRunner({ signal }, __dirname, 'scenario-headers.ts') .withEnv({ SERVER_URL }) .expect({ transaction: {}, @@ -60,10 +60,10 @@ test('adds current transaction name to baggage when the txn name is high-quality closeTestServer(); }); -test('adds current transaction name to trace envelope header when the txn name is high-quality', async () => { +test('adds current transaction name to trace envelope header when the txn name is high-quality', async ({ signal }) => { expect.assertions(4); - await createRunner(__dirname, 'scenario-events.ts') + await createRunner({ signal }, __dirname, 'scenario-events.ts') .expectHeader({ event: { trace: { diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts index bba04c788282..390098dfdfc8 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts @@ -1,8 +1,8 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; -test('envelope header for error event during active unsampled span is correct', async () => { - await createRunner(__dirname, 'scenario.ts') +test('envelope header for error event during active unsampled span is correct', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .ignore('transaction') .expectHeader({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts index f11defc490c8..92febd112b13 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts @@ -1,8 +1,8 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; -test('envelope header for error event during active span is correct', async () => { - await createRunner(__dirname, 'scenario.ts') +test('envelope header for error event during active span is correct', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .ignore('transaction') .expectHeader({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error/test.ts index 9d39209d456f..61e29c31d4af 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error/test.ts @@ -1,8 +1,8 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; -test('envelope header for error events is correct', async () => { - await createRunner(__dirname, 'scenario.ts') +test('envelope header for error events is correct', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expectHeader({ event: { trace: { diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/sampleRate-propagation/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/sampleRate-propagation/test.ts index 63db6ff4e820..c3c8d01e3e59 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/sampleRate-propagation/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/sampleRate-propagation/test.ts @@ -8,8 +8,8 @@ describe('tracesSampleRate propagation', () => { const traceId = '12345678123456781234567812345678'; - test('uses sample rate from incoming baggage header in trace envelope item', async () => { - const runner = createRunner(__dirname, 'server.js') + test('uses sample rate from incoming baggage header in trace envelope item', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .expectHeader({ transaction: { trace: { diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts index f4bb6e2b4293..b13f20d0b207 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts @@ -1,8 +1,8 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; -test('envelope header for transaction event of route correct', async () => { - await createRunner(__dirname, 'scenario.ts') +test('envelope header for transaction event of route correct', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expectHeader({ transaction: { trace: { diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts index c4ed5ae4983f..7e58cc538d42 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts @@ -1,8 +1,8 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; -test('envelope header for transaction event with source=url correct', async () => { - await createRunner(__dirname, 'scenario.ts') +test('envelope header for transaction event with source=url correct', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expectHeader({ transaction: { trace: { diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction/test.ts index 104761d52c86..c5eee7ea9be4 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction/test.ts @@ -1,8 +1,8 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; -test('envelope header for transaction event is correct', async () => { - await createRunner(__dirname, 'scenario.ts') +test('envelope header for transaction event is correct', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.ts') .expectHeader({ transaction: { trace: { diff --git a/dev-packages/node-integration-tests/suites/tracing/genericPool/test.ts b/dev-packages/node-integration-tests/suites/tracing/genericPool/test.ts index dd18c456e958..92ee243f80ab 100644 --- a/dev-packages/node-integration-tests/suites/tracing/genericPool/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/genericPool/test.ts @@ -7,7 +7,7 @@ describe('genericPool auto instrumentation', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('should auto-instrument `genericPool` package when calling pool.require()', async () => { + test('should auto-instrument `genericPool` package when calling pool.require()', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction', spans: expect.arrayContaining([ @@ -31,7 +31,7 @@ describe('genericPool auto instrumentation', () => { ]), }; - await createRunner().expect({ transaction: EXPECTED_TRANSACTION }).start().completed(); + await createRunner({ signal }).expect({ transaction: EXPECTED_TRANSACTION }).start().completed(); }); }); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/google-genai/test.ts b/dev-packages/node-integration-tests/suites/tracing/google-genai/test.ts index 92d669c7e10f..c397b4bba855 100644 --- a/dev-packages/node-integration-tests/suites/tracing/google-genai/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/google-genai/test.ts @@ -175,8 +175,8 @@ describe('Google GenAI integration', () => { }; createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('creates google genai related spans with sendDefaultPii: false', async () => { - await createRunner() + test('creates google genai related spans with sendDefaultPii: false', async ({ signal }) => { + await createRunner({ signal }) .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }) .start() @@ -185,8 +185,8 @@ describe('Google GenAI integration', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('creates google genai related spans with sendDefaultPii: true', async () => { - await createRunner() + test('creates google genai related spans with sendDefaultPii: true', async ({ signal }) => { + await createRunner({ signal }) .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_TRUE }) .start() @@ -195,8 +195,8 @@ describe('Google GenAI integration', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument-with-options.mjs', (createRunner, test) => { - test('creates google genai related spans with custom options', async () => { - await createRunner() + test('creates google genai related spans with custom options', async ({ signal }) => { + await createRunner({ signal }) .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION_WITH_OPTIONS }) .start() @@ -275,8 +275,12 @@ describe('Google GenAI integration', () => { }; createEsmAndCjsTests(__dirname, 'scenario-tools.mjs', 'instrument-with-options.mjs', (createRunner, test) => { - test('creates google genai related spans with tool calls', async () => { - await createRunner().ignore('event').expect({ transaction: EXPECTED_TRANSACTION_TOOLS }).start().completed(); + test('creates google genai related spans with tool calls', async ({ signal }) => { + await createRunner({ signal }) + .ignore('event') + .expect({ transaction: EXPECTED_TRANSACTION_TOOLS }) + .start() + .completed(); }); }); @@ -472,14 +476,18 @@ describe('Google GenAI integration', () => { }; createEsmAndCjsTests(__dirname, 'scenario-streaming.mjs', 'instrument.mjs', (createRunner, test) => { - test('creates google genai streaming spans with sendDefaultPii: false', async () => { - await createRunner().ignore('event').expect({ transaction: EXPECTED_TRANSACTION_STREAMING }).start().completed(); + test('creates google genai streaming spans with sendDefaultPii: false', async ({ signal }) => { + await createRunner({ signal }) + .ignore('event') + .expect({ transaction: EXPECTED_TRANSACTION_STREAMING }) + .start() + .completed(); }); }); createEsmAndCjsTests(__dirname, 'scenario-streaming.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('creates google genai streaming spans with sendDefaultPii: true', async () => { - await createRunner() + test('creates google genai streaming spans with sendDefaultPii: true', async ({ signal }) => { + await createRunner({ signal }) .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION_STREAMING_PII_TRUE }) .start() diff --git a/dev-packages/node-integration-tests/suites/tracing/hapi/test.ts b/dev-packages/node-integration-tests/suites/tracing/hapi/test.ts index 5693f55a6a8c..270943182f8a 100644 --- a/dev-packages/node-integration-tests/suites/tracing/hapi/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/hapi/test.ts @@ -37,14 +37,14 @@ describe('hapi auto-instrumentation', () => { }; createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('should auto-instrument `@hapi/hapi` package.', async () => { - const runner = createRunner().expect({ transaction: EXPECTED_TRANSACTION }).start(); + test('should auto-instrument `@hapi/hapi` package.', async ({ signal }) => { + const runner = createRunner({ signal }).expect({ transaction: EXPECTED_TRANSACTION }).start(); runner.makeRequest('get', '/'); await runner.completed(); }); - test('should handle returned plain errors in routes.', async () => { - const runner = createRunner() + test('should handle returned plain errors in routes.', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /error', @@ -56,8 +56,8 @@ describe('hapi auto-instrumentation', () => { await runner.completed(); }); - test('should assign parameterized transactionName to error.', async () => { - const runner = createRunner() + test('should assign parameterized transactionName to error.', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ event: { ...EXPECTED_ERROR_EVENT, @@ -70,8 +70,8 @@ describe('hapi auto-instrumentation', () => { await runner.completed(); }); - test('should handle returned Boom errors in routes.', async () => { - const runner = createRunner() + test('should handle returned Boom errors in routes.', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /boom-error', @@ -83,8 +83,8 @@ describe('hapi auto-instrumentation', () => { await runner.completed(); }); - test('should handle promise rejections in routes.', async () => { - const runner = createRunner() + test('should handle promise rejections in routes.', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /promise-error', diff --git a/dev-packages/node-integration-tests/suites/tracing/hono/test.ts b/dev-packages/node-integration-tests/suites/tracing/hono/test.ts index 67d0ff8b56fb..23fa7d013b17 100644 --- a/dev-packages/node-integration-tests/suites/tracing/hono/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/hono/test.ts @@ -10,8 +10,8 @@ describe('hono tracing', () => { describe.each(['/sync', '/async'] as const)('when using %s route', route => { describe.each(['get', 'post', 'put', 'delete', 'patch'] as const)('when using %s method', method => { describe.each(['/', '/all', '/on'])('when using %s path', path => { - test('should handle transaction', async () => { - const runner = createRunner() + test('should handle transaction', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: `${method.toUpperCase()} ${route}${path === '/' ? '' : path}`, @@ -69,8 +69,8 @@ describe('hono tracing', () => { await runner.completed(); }); - test('should handle transaction with anonymous middleware', async () => { - const runner = createRunner() + test('should handle transaction with anonymous middleware', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: `${method.toUpperCase()} ${route}${path === '/' ? '' : path}/middleware`, @@ -137,8 +137,8 @@ describe('hono tracing', () => { await runner.completed(); }); - test('should handle transaction with separate middleware', async () => { - const runner = createRunner() + test('should handle transaction with separate middleware', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: `${method.toUpperCase()} ${route}${path === '/' ? '' : path}/middleware/separately`, @@ -205,8 +205,8 @@ describe('hono tracing', () => { await runner.completed(); }); - test('should handle returned errors for %s path', async () => { - const runner = createRunner() + test('should handle returned errors for %s path', async ({ signal }) => { + const runner = createRunner({ signal }) .ignore('transaction') .expect({ event: { @@ -229,10 +229,10 @@ describe('hono tracing', () => { await runner.completed(); }); - test.each(['/401', '/402', '/403', '/does-not-exist'])( + test.for(['/401', '/402', '/403', '/does-not-exist'])( 'should ignores error %s path by default', - async (subPath: string) => { - const runner = createRunner() + async (subPath, { signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: `${method.toUpperCase()} ${route}`, diff --git a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-basic/test.ts b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-basic/test.ts index 1b599def6be6..222736f619e6 100644 --- a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-basic/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-basic/test.ts @@ -2,10 +2,10 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; import { createTestServer } from '../../../../utils/server'; -test('captures spans for outgoing fetch requests', async () => { +test('captures spans for outgoing fetch requests', async ({ signal }) => { expect.assertions(3); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', () => { // Just ensure we're called expect(true).toBe(true); @@ -20,7 +20,7 @@ test('captures spans for outgoing fetch requests', async () => { ) .start(); - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .withEnv({ SERVER_URL }) .expect({ transaction: { diff --git a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-strip-query/test.ts b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-strip-query/test.ts index 797047080283..a432a455da26 100644 --- a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-strip-query/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-strip-query/test.ts @@ -2,17 +2,17 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; import { createTestServer } from '../../../../utils/server'; -test('strips and handles query params in spans of outgoing fetch requests', async () => { +test('strips and handles query params in spans of outgoing fetch requests', async ({ signal }) => { expect.assertions(4); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0/users', () => { // Just ensure we're called expect(true).toBe(true); }) .start(); - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .withEnv({ SERVER_URL }) .expect({ transaction: txn => { diff --git a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-basic/test.ts b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-basic/test.ts index bb21f7def8f0..318cbdf79ff8 100644 --- a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-basic/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-basic/test.ts @@ -2,10 +2,10 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; import { createTestServer } from '../../../../utils/server'; -test('captures spans for outgoing http requests', async () => { +test('captures spans for outgoing http requests', async ({ signal }) => { expect.assertions(3); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', () => { // Just ensure we're called expect(true).toBe(true); @@ -20,7 +20,7 @@ test('captures spans for outgoing http requests', async () => { ) .start(); - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .withEnv({ SERVER_URL }) .expect({ transaction: { diff --git a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-strip-query/test.ts b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-strip-query/test.ts index ebe2eff07013..beeb1acfb4d4 100644 --- a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-strip-query/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-strip-query/test.ts @@ -2,17 +2,17 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../../utils/runner'; import { createTestServer } from '../../../../utils/server'; -test('strips and handles query params in spans of outgoing http requests', async () => { +test('strips and handles query params in spans of outgoing http requests', async ({ signal }) => { expect.assertions(4); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0/users', () => { // Just ensure we're called expect(true).toBe(true); }) .start(); - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .withEnv({ SERVER_URL }) .expect({ transaction: txn => { diff --git a/dev-packages/node-integration-tests/suites/tracing/httpIntegration/test.ts b/dev-packages/node-integration-tests/suites/tracing/httpIntegration/test.ts index 48fab1be2e9d..40a456a0bdcb 100644 --- a/dev-packages/node-integration-tests/suites/tracing/httpIntegration/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/httpIntegration/test.ts @@ -21,8 +21,8 @@ describe('httpIntegration', () => { describe('instrumentation options', () => { createEsmAndCjsTests(__dirname, 'server.mjs', 'instrument-options.mjs', (createRunner, test) => { - test('allows to pass instrumentation options to integration', async () => { - const runner = createRunner() + test('allows to pass instrumentation options to integration', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { contexts: { @@ -63,8 +63,8 @@ describe('httpIntegration', () => { await runner.completed(); }); - test('allows to configure incomingRequestSpanHook', async () => { - const runner = createRunner() + test('allows to configure incomingRequestSpanHook', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { contexts: { @@ -99,8 +99,8 @@ describe('httpIntegration', () => { describe('http.server spans', () => { createEsmAndCjsTests(__dirname, 'server.mjs', 'instrument.mjs', (createRunner, test) => { - test('captures correct attributes for GET requests', async () => { - const runner = createRunner() + test('captures correct attributes for GET requests', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: transaction => { const port = runner.getPort(); @@ -140,8 +140,8 @@ describe('httpIntegration', () => { await runner.completed(); }); - test('captures correct attributes for POST requests', async () => { - const runner = createRunner() + test('captures correct attributes for POST requests', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: transaction => { const port = runner.getPort(); @@ -191,8 +191,8 @@ describe('httpIntegration', () => { 'scenario-overwrite-server-emit.mjs', 'instrument-overwrite-server-emit.mjs', (createRunner, test) => { - test('handles server.emit being overwritten via classic monkey patching', async () => { - const runner = createRunner() + test('handles server.emit being overwritten via classic monkey patching', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /test1', @@ -249,8 +249,8 @@ describe('httpIntegration', () => { await runner.completed(); }); - test('handles server.emit being overwritten via proxy', async () => { - const runner = createRunner() + test('handles server.emit being overwritten via proxy', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /test1-proxy', @@ -306,8 +306,10 @@ describe('httpIntegration', () => { await runner.completed(); }); - test('handles server.emit being overwritten via classic monkey patching, using initial server.emit', async () => { - const runner = createRunner() + test('handles server.emit being overwritten via classic monkey patching, using initial server.emit', async ({ + signal, + }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /test1-original', @@ -364,8 +366,8 @@ describe('httpIntegration', () => { await runner.completed(); }); - test('handles server.emit being overwritten via proxy, using initial server.emit', async () => { - const runner = createRunner() + test('handles server.emit being overwritten via proxy, using initial server.emit', async ({ signal }) => { + const runner = createRunner({ signal }) .expect({ transaction: { transaction: 'GET /test1-proxy-original', @@ -427,8 +429,8 @@ describe('httpIntegration', () => { }); describe("doesn't create a root span for incoming requests ignored via `ignoreIncomingRequests`", () => { - test('via the url param', async () => { - const runner = createRunner(__dirname, 'server-ignoreIncomingRequests.js') + test('via the url param', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server-ignoreIncomingRequests.js') .expect({ transaction: { contexts: { @@ -453,8 +455,8 @@ describe('httpIntegration', () => { await runner.completed(); }); - test('via the request param', async () => { - const runner = createRunner(__dirname, 'server-ignoreIncomingRequests.js') + test('via the request param', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server-ignoreIncomingRequests.js') .expect({ transaction: { contexts: { @@ -481,13 +483,13 @@ describe('httpIntegration', () => { }); describe("doesn't create child spans or breadcrumbs for outgoing requests ignored via `ignoreOutgoingRequests`", () => { - test('via the url param', async () => { - const [SERVER_URL, closeTestServer] = await createTestServer() + test('via the url param', async ({ signal }) => { + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/blockUrl', () => {}, 200) .get('/pass', () => {}, 200) .start(); - const runner = createRunner(__dirname, 'server-ignoreOutgoingRequests.js') + const runner = createRunner({ signal }, __dirname, 'server-ignoreOutgoingRequests.js') .withEnv({ SERVER_URL }) .expect({ transaction: event => { @@ -508,13 +510,13 @@ describe('httpIntegration', () => { closeTestServer(); }); - test('via the request param', async () => { - const [SERVER_URL, closeTestServer] = await createTestServer() + test('via the request param', async ({ signal }) => { + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/blockUrl', () => {}, 200) .get('/pass', () => {}, 200) .start(); - const runner = createRunner(__dirname, 'server-ignoreOutgoingRequests.js') + const runner = createRunner({ signal }, __dirname, 'server-ignoreOutgoingRequests.js') .withEnv({ SERVER_URL }) .expect({ transaction: event => { @@ -537,8 +539,8 @@ describe('httpIntegration', () => { }); }); - test('ignores static asset requests by default', async () => { - const runner = createRunner(__dirname, 'server-ignoreStaticAssets.js') + test('ignores static asset requests by default', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server-ignoreStaticAssets.js') .expect({ transaction: event => { expect(event.transaction).toBe('GET /test'); @@ -560,8 +562,8 @@ describe('httpIntegration', () => { await runner.completed(); }); - test('traces static asset requests when ignoreStaticAssets is false', async () => { - const runner = createRunner(__dirname, 'server-traceStaticAssets.js') + test('traces static asset requests when ignoreStaticAssets is false', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server-traceStaticAssets.js') .expect({ transaction: event => { expect(event.transaction).toBe('GET /favicon.ico'); diff --git a/dev-packages/node-integration-tests/suites/tracing/kafkajs/test.ts b/dev-packages/node-integration-tests/suites/tracing/kafkajs/test.ts index 176d947e1ecf..0bef4817e259 100644 --- a/dev-packages/node-integration-tests/suites/tracing/kafkajs/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/kafkajs/test.ts @@ -7,8 +7,8 @@ describe('kafkajs', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('traces producers and consumers', { timeout: 60_000 }, async () => { - await createRunner() + test('traces producers and consumers', { timeout: 60_000 }, async ({ signal }) => { + await createRunner({ signal }) .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['9092'], diff --git a/dev-packages/node-integration-tests/suites/tracing/knex/mysql2/test.ts b/dev-packages/node-integration-tests/suites/tracing/knex/mysql2/test.ts index e8116293de09..634f12cc4153 100644 --- a/dev-packages/node-integration-tests/suites/tracing/knex/mysql2/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/knex/mysql2/test.ts @@ -7,7 +7,7 @@ describe('knex auto instrumentation', () => { describe('with `mysql2` client', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('should auto-instrument `knex` package', { timeout: 60_000 }, async () => { + test('should auto-instrument `knex` package', { timeout: 60_000 }, async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction', spans: expect.arrayContaining([ @@ -62,7 +62,7 @@ describe('knex auto instrumentation', () => { ]), }; - await createRunner() + await createRunner({ signal }) .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port: 3306'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() diff --git a/dev-packages/node-integration-tests/suites/tracing/knex/pg/test.ts b/dev-packages/node-integration-tests/suites/tracing/knex/pg/test.ts index 7c38381eb125..a64f8b7f16b3 100644 --- a/dev-packages/node-integration-tests/suites/tracing/knex/pg/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/knex/pg/test.ts @@ -7,7 +7,7 @@ describe('knex auto instrumentation', () => { describe('with `pg` client', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('should auto-instrument `knex` package', { timeout: 60_000 }, async () => { + test('should auto-instrument `knex` package', { timeout: 60_000 }, async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction', spans: expect.arrayContaining([ @@ -60,7 +60,7 @@ describe('knex auto instrumentation', () => { ]), }; - await createRunner() + await createRunner({ signal }) .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() diff --git a/dev-packages/node-integration-tests/suites/tracing/linking/test.ts b/dev-packages/node-integration-tests/suites/tracing/linking/test.ts index a0874274d2bd..6d4120311c4d 100644 --- a/dev-packages/node-integration-tests/suites/tracing/linking/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/linking/test.ts @@ -2,10 +2,10 @@ import { describe, expect, test } from 'vitest'; import { createRunner } from '../../../utils/runner'; describe('span links', () => { - test('should link spans by adding "links" to span options', async () => { + test('should link spans by adding "links" to span options', async ({ signal }) => { let span1_traceId: string, span1_spanId: string; - await createRunner(__dirname, 'scenario-span-options.ts') + await createRunner({ signal }, __dirname, 'scenario-span-options.ts') .expect({ transaction: event => { expect(event.transaction).toBe('parent1'); @@ -33,10 +33,10 @@ describe('span links', () => { .completed(); }); - test('should link spans with addLink() in trace context', async () => { + test('should link spans with addLink() in trace context', async ({ signal }) => { let span1_traceId: string, span1_spanId: string; - await createRunner(__dirname, 'scenario-addLink.ts') + await createRunner({ signal }, __dirname, 'scenario-addLink.ts') .expect({ transaction: event => { expect(event.transaction).toBe('span1'); @@ -66,10 +66,10 @@ describe('span links', () => { .completed(); }); - test('should link spans with addLinks() in trace context', async () => { + test('should link spans with addLinks() in trace context', async ({ signal }) => { let span1_traceId: string, span1_spanId: string, span2_traceId: string, span2_spanId: string; - await createRunner(__dirname, 'scenario-addLinks.ts') + await createRunner({ signal }, __dirname, 'scenario-addLinks.ts') .expect({ transaction: event => { expect(event.transaction).toBe('span1'); @@ -114,8 +114,8 @@ describe('span links', () => { .completed(); }); - test('should link spans with addLink() in nested startSpan() calls', async () => { - await createRunner(__dirname, 'scenario-addLink-nested.ts') + test('should link spans with addLink() in nested startSpan() calls', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario-addLink-nested.ts') .expect({ transaction: event => { expect(event.transaction).toBe('parent1'); @@ -154,8 +154,8 @@ describe('span links', () => { .completed(); }); - test('should link spans with addLinks() in nested startSpan() calls', async () => { - await createRunner(__dirname, 'scenario-addLinks-nested.ts') + test('should link spans with addLinks() in nested startSpan() calls', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario-addLinks-nested.ts') .expect({ transaction: event => { expect(event.transaction).toBe('parent1'); diff --git a/dev-packages/node-integration-tests/suites/tracing/lru-memoizer/test.ts b/dev-packages/node-integration-tests/suites/tracing/lru-memoizer/test.ts index 7caccfc97144..11757824eeff 100644 --- a/dev-packages/node-integration-tests/suites/tracing/lru-memoizer/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/lru-memoizer/test.ts @@ -6,8 +6,8 @@ describe('lru-memoizer', () => { cleanupChildProcesses(); }); - test('keeps outer context inside the memoized inner functions', async () => { - await createRunner(__dirname, 'scenario.js') + test('keeps outer context inside the memoized inner functions', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.js') // We expect only one transaction and nothing else. // A failed test will result in an error event being sent to Sentry. // Which will fail this suite. diff --git a/dev-packages/node-integration-tests/suites/tracing/maxSpans/test.ts b/dev-packages/node-integration-tests/suites/tracing/maxSpans/test.ts index 31b0af762d9a..61890453c686 100644 --- a/dev-packages/node-integration-tests/suites/tracing/maxSpans/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/maxSpans/test.ts @@ -2,13 +2,13 @@ import type { SpanJSON } from '@sentry/core'; import { expect, test } from 'vitest'; import { createRunner } from '../../../utils/runner'; -test('it limits spans to 1000', async () => { +test('it limits spans to 1000', async ({ signal }) => { const expectedSpans: SpanJSON[] = []; for (let i = 0; i < 1000; i++) { expectedSpans.push(expect.objectContaining({ description: `child ${i}` })); } - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .expect({ transaction: { transaction: 'parent', diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts index 7c6612a0f4f7..15854da1cfb7 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts @@ -7,8 +7,8 @@ describe('errors in TwP mode have same trace in trace context and getTraceData() }); // In a request handler, the spanId is consistent inside of the request - test('in incoming request', async () => { - const runner = createRunner(__dirname, 'server.js') + test('in incoming request', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js') .expect({ event: event => { const { contexts } = event; @@ -34,8 +34,8 @@ describe('errors in TwP mode have same trace in trace context and getTraceData() }); // Outside of a request handler, the spanId is random - test('outside of a request handler', async () => { - await createRunner(__dirname, 'no-server.js') + test('outside of a request handler', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'no-server.js') .expect({ event: event => { const { contexts } = event; diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp/test.ts index c719a82ceb36..e6eb8b200bca 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp/test.ts @@ -6,8 +6,10 @@ describe('getTraceMetaTags', () => { cleanupChildProcesses(); }); - test('injects sentry tracing tags without sampled flag for Tracing Without Performance', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('injects sentry tracing tags without sampled flag for Tracing Without Performance', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/test'); diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts index c1b88699d8a0..4fa5d4e1be38 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts @@ -6,11 +6,11 @@ describe('getTraceMetaTags', () => { cleanupChildProcesses(); }); - test('injects tags with trace from incoming headers', async () => { + test('injects tags with trace from incoming headers', async ({ signal }) => { const traceId = 'cd7ee7a6fe3ebe7ab9c3271559bc203c'; const parentSpanId = '100ff0980e7a4ead'; - const runner = createRunner(__dirname, 'server.js').start(); + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest<{ response: string }>('get', '/test', { headers: { @@ -25,8 +25,8 @@ describe('getTraceMetaTags', () => { expect(html).toContain(''); }); - test('injects tags with new trace if no incoming headers', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('injects tags with new trace if no incoming headers', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest<{ response: string }>('get', '/test'); @@ -39,8 +39,8 @@ describe('getTraceMetaTags', () => { expect(html).toContain(`sentry-trace_id=${traceId}`); }); - test('injects tags with negative sampling decision if tracesSampleRate is 0', async () => { - const runner = createRunner(__dirname, 'server-tracesSampleRate-zero.js').start(); + test('injects tags with negative sampling decision if tracesSampleRate is 0', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server-tracesSampleRate-zero.js').start(); const response = await runner.makeRequest<{ response: string }>('get', '/test'); @@ -54,11 +54,11 @@ describe('getTraceMetaTags', () => { expect(html).toContain('sentry-sampled=false'); }); - test("doesn't inject sentry tracing tags if SDK is disabled", async () => { + test("doesn't inject sentry tracing tags if SDK is disabled", async ({ signal }) => { const traceId = 'cd7ee7a6fe3ebe7ab9c3271559bc203c'; const parentSpanId = '100ff0980e7a4ead'; - const runner = createRunner(__dirname, 'server-sdk-disabled.js').start(); + const runner = createRunner({ signal }, __dirname, 'server-sdk-disabled.js').start(); const response = await runner.makeRequest<{ response: string }>('get', '/test', { headers: { diff --git a/dev-packages/node-integration-tests/suites/tracing/mongodb/test.ts b/dev-packages/node-integration-tests/suites/tracing/mongodb/test.ts index 8c16e8b36133..3d6503a606db 100644 --- a/dev-packages/node-integration-tests/suites/tracing/mongodb/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/mongodb/test.ts @@ -170,7 +170,10 @@ describe('MongoDB experimental Test', () => { ], }; - test('CJS - should auto-instrument `mongodb` package.', async () => { - await createRunner(__dirname, 'scenario.js').expect({ transaction: EXPECTED_TRANSACTION }).start().completed(); + test('CJS - should auto-instrument `mongodb` package.', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.js') + .expect({ transaction: EXPECTED_TRANSACTION }) + .start() + .completed(); }); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/mongoose/test.ts b/dev-packages/node-integration-tests/suites/tracing/mongoose/test.ts index 5c961a2af19e..04fc1de96be1 100644 --- a/dev-packages/node-integration-tests/suites/tracing/mongoose/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/mongoose/test.ts @@ -45,7 +45,10 @@ describe('Mongoose experimental Test', () => { ]), }; - test('CJS - should auto-instrument `mongoose` package.', async () => { - await createRunner(__dirname, 'scenario.js').expect({ transaction: EXPECTED_TRANSACTION }).start().completed(); + test('CJS - should auto-instrument `mongoose` package.', async ({ signal }) => { + await createRunner({ signal }, __dirname, 'scenario.js') + .expect({ transaction: EXPECTED_TRANSACTION }) + .start() + .completed(); }); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/mysql/test.ts b/dev-packages/node-integration-tests/suites/tracing/mysql/test.ts index adb35f1c0025..85f490f001ab 100644 --- a/dev-packages/node-integration-tests/suites/tracing/mysql/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/mysql/test.ts @@ -6,7 +6,7 @@ describe('mysql auto instrumentation', () => { cleanupChildProcesses(); }); - test('should auto-instrument `mysql` package when using connection.connect()', async () => { + test('should auto-instrument `mysql` package when using connection.connect()', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction', spans: expect.arrayContaining([ @@ -33,13 +33,13 @@ describe('mysql auto instrumentation', () => { ]), }; - await createRunner(__dirname, 'scenario-withConnect.js') + await createRunner({ signal }, __dirname, 'scenario-withConnect.js') .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('should auto-instrument `mysql` package when using query without callback', async () => { + test('should auto-instrument `mysql` package when using query without callback', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction', spans: expect.arrayContaining([ @@ -66,13 +66,13 @@ describe('mysql auto instrumentation', () => { ]), }; - await createRunner(__dirname, 'scenario-withoutCallback.js') + await createRunner({ signal }, __dirname, 'scenario-withoutCallback.js') .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('should auto-instrument `mysql` package without connection.connect()', async () => { + test('should auto-instrument `mysql` package without connection.connect()', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction', spans: expect.arrayContaining([ @@ -99,7 +99,7 @@ describe('mysql auto instrumentation', () => { ]), }; - await createRunner(__dirname, 'scenario-withoutConnect.js') + await createRunner({ signal }, __dirname, 'scenario-withoutConnect.js') .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); diff --git a/dev-packages/node-integration-tests/suites/tracing/mysql2/test.ts b/dev-packages/node-integration-tests/suites/tracing/mysql2/test.ts index c1d680b9a52e..c6253334b0f0 100644 --- a/dev-packages/node-integration-tests/suites/tracing/mysql2/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/mysql2/test.ts @@ -6,37 +6,41 @@ describe('mysql2 auto instrumentation', () => { cleanupChildProcesses(); }); - test('should auto-instrument `mysql` package without connection.connect()', { timeout: 75_000 }, async () => { - const EXPECTED_TRANSACTION = { - transaction: 'Test Transaction', - spans: expect.arrayContaining([ - expect.objectContaining({ - description: 'SELECT 1 + 1 AS solution', - op: 'db', - data: expect.objectContaining({ - 'db.system': 'mysql', - 'net.peer.name': 'localhost', - 'net.peer.port': 3306, - 'db.user': 'root', + test( + 'should auto-instrument `mysql` package without connection.connect()', + { timeout: 75_000 }, + async ({ signal }) => { + const EXPECTED_TRANSACTION = { + transaction: 'Test Transaction', + spans: expect.arrayContaining([ + expect.objectContaining({ + description: 'SELECT 1 + 1 AS solution', + op: 'db', + data: expect.objectContaining({ + 'db.system': 'mysql', + 'net.peer.name': 'localhost', + 'net.peer.port': 3306, + 'db.user': 'root', + }), }), - }), - expect.objectContaining({ - description: 'SELECT NOW()', - op: 'db', - data: expect.objectContaining({ - 'db.system': 'mysql', - 'net.peer.name': 'localhost', - 'net.peer.port': 3306, - 'db.user': 'root', + expect.objectContaining({ + description: 'SELECT NOW()', + op: 'db', + data: expect.objectContaining({ + 'db.system': 'mysql', + 'net.peer.name': 'localhost', + 'net.peer.port': 3306, + 'db.user': 'root', + }), }), - }), - ]), - }; + ]), + }; - await createRunner(__dirname, 'scenario.js') - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port: 3306'] }) - .expect({ transaction: EXPECTED_TRANSACTION }) - .start() - .completed(); - }); + await createRunner({ signal }, __dirname, 'scenario.js') + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port: 3306'] }) + .expect({ transaction: EXPECTED_TRANSACTION }) + .start() + .completed(); + }, + ); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/openai/openai-tool-calls/test.ts b/dev-packages/node-integration-tests/suites/tracing/openai/openai-tool-calls/test.ts index 98dab6e77b86..3b30b55b5c8b 100644 --- a/dev-packages/node-integration-tests/suites/tracing/openai/openai-tool-calls/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/openai/openai-tool-calls/test.ts @@ -295,8 +295,8 @@ describe('OpenAI Tool Calls integration', () => { }; createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('creates openai tool calls related spans with sendDefaultPii: false', async () => { - await createRunner() + test('creates openai tool calls related spans with sendDefaultPii: false', async ({ signal }) => { + await createRunner({ signal }) .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }) .start() @@ -305,8 +305,8 @@ describe('OpenAI Tool Calls integration', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('creates openai tool calls related spans with sendDefaultPii: true', async () => { - await createRunner() + test('creates openai tool calls related spans with sendDefaultPii: true', async ({ signal }) => { + await createRunner({ signal }) .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_TRUE }) .start() diff --git a/dev-packages/node-integration-tests/suites/tracing/openai/test.ts b/dev-packages/node-integration-tests/suites/tracing/openai/test.ts index c0c0b79e95f7..d8f87060493d 100644 --- a/dev-packages/node-integration-tests/suites/tracing/openai/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/openai/test.ts @@ -322,8 +322,8 @@ describe('OpenAI integration', () => { }; createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('creates openai related spans with sendDefaultPii: false', async () => { - await createRunner() + test('creates openai related spans with sendDefaultPii: false', async ({ signal }) => { + await createRunner({ signal }) .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }) .start() @@ -332,8 +332,8 @@ describe('OpenAI integration', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('creates openai related spans with sendDefaultPii: true', async () => { - await createRunner() + test('creates openai related spans with sendDefaultPii: true', async ({ signal }) => { + await createRunner({ signal }) .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_TRUE }) .start() @@ -342,8 +342,8 @@ describe('OpenAI integration', () => { }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument-with-options.mjs', (createRunner, test) => { - test('creates openai related spans with custom options', async () => { - await createRunner() + test('creates openai related spans with custom options', async ({ signal }) => { + await createRunner({ signal }) .ignore('event') .expect({ transaction: EXPECTED_TRANSACTION_WITH_OPTIONS }) .start() @@ -352,8 +352,8 @@ describe('OpenAI integration', () => { }); createEsmAndCjsTests(__dirname, 'scenario-root-span.mjs', 'instrument.mjs', (createRunner, test) => { - test('it works without a wrapping span', async () => { - await createRunner() + test('it works without a wrapping span', async ({ signal }) => { + await createRunner({ signal }) // First the span that our mock express server is emitting, unrelated to this test .expect({ transaction: { diff --git a/dev-packages/node-integration-tests/suites/tracing/postgres/test.ts b/dev-packages/node-integration-tests/suites/tracing/postgres/test.ts index b0d0649a1ac9..99cc55eea22b 100644 --- a/dev-packages/node-integration-tests/suites/tracing/postgres/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/postgres/test.ts @@ -2,7 +2,7 @@ import { describe, expect, test } from 'vitest'; import { createRunner } from '../../../utils/runner'; describe('postgres auto instrumentation', () => { - test('should auto-instrument `pg` package', { timeout: 90_000 }, async () => { + test('should auto-instrument `pg` package', { timeout: 90_000 }, async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction', spans: expect.arrayContaining([ @@ -46,7 +46,7 @@ describe('postgres auto instrumentation', () => { ]), }; - await createRunner(__dirname, 'scenario.js') + await createRunner({ signal }, __dirname, 'scenario.js') .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'], @@ -57,7 +57,7 @@ describe('postgres auto instrumentation', () => { .completed(); }); - test('should auto-instrument `pg-native` package', { timeout: 90_000 }, async () => { + test('should auto-instrument `pg-native` package', { timeout: 90_000 }, async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction', spans: expect.arrayContaining([ @@ -101,7 +101,7 @@ describe('postgres auto instrumentation', () => { ]), }; - await createRunner(__dirname, 'scenario-native.js') + await createRunner({ signal }, __dirname, 'scenario-native.js') .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'], diff --git a/dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts b/dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts index 68b1a82703a0..871c4f4fe64e 100644 --- a/dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts @@ -5,7 +5,7 @@ const EXISTING_TEST_EMAIL = 'bar@baz.com'; const NON_EXISTING_TEST_EMAIL = 'foo@baz.com'; describe('postgresjs auto instrumentation', () => { - test('should auto-instrument `postgres` package', { timeout: 60_000 }, async () => { + test('should auto-instrument `postgres` package', { timeout: 60_000 }, async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction', spans: expect.arrayContaining([ @@ -215,7 +215,7 @@ describe('postgresjs auto instrumentation', () => { }, }; - await createRunner(__dirname, 'scenario.js') + await createRunner({ signal }, __dirname, 'scenario.js') .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .expect({ event: EXPECTED_ERROR_EVENT }) diff --git a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/test.ts b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/test.ts index 74bdf4be4bd2..8f04c2cf9b1b 100644 --- a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v5/test.ts @@ -11,8 +11,8 @@ describe('Prisma ORM v5 Tests', () => { 'scenario.mjs', 'instrument.mjs', (createRunner, test, _mode, cwd) => { - test('should instrument PostgreSQL queries from Prisma ORM', { timeout: 75_000 }, async () => { - await createRunner() + test('should instrument PostgreSQL queries from Prisma ORM', { timeout: 75_000 }, async ({ signal }) => { + await createRunner({ signal }) .withDockerCompose({ workingDirectory: [cwd], readyMatches: ['port 5432'], diff --git a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/test.ts b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/test.ts index 07405a496fd0..74ca8833c53b 100644 --- a/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/prisma-orm-v6/test.ts @@ -12,8 +12,8 @@ describe('Prisma ORM v6 Tests', () => { 'scenario.mjs', 'instrument.mjs', (createRunner, test, _mode, cwd) => { - test('should instrument PostgreSQL queries from Prisma ORM', { timeout: 75_000 }, async () => { - await createRunner() + test('should instrument PostgreSQL queries from Prisma ORM', { timeout: 75_000 }, async ({ signal }) => { + await createRunner({ signal }) .withDockerCompose({ workingDirectory: [cwd], readyMatches: ['port 5432'], diff --git a/dev-packages/node-integration-tests/suites/tracing/redis-cache/test.ts b/dev-packages/node-integration-tests/suites/tracing/redis-cache/test.ts index e1aa0b9c1494..04dc0c9c2620 100644 --- a/dev-packages/node-integration-tests/suites/tracing/redis-cache/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/redis-cache/test.ts @@ -6,7 +6,7 @@ describe('redis cache auto instrumentation', () => { cleanupChildProcesses(); }); - test('should not add cache spans when key is not prefixed', { timeout: 60_000 }, async () => { + test('should not add cache spans when key is not prefixed', { timeout: 60_000 }, async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Span', spans: expect.arrayContaining([ @@ -37,14 +37,14 @@ describe('redis cache auto instrumentation', () => { ]), }; - await createRunner(__dirname, 'scenario-ioredis.js') + await createRunner({ signal }, __dirname, 'scenario-ioredis.js') .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port=6379'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('should create cache spans for prefixed keys (ioredis)', { timeout: 60_000 }, async () => { + test('should create cache spans for prefixed keys (ioredis)', { timeout: 60_000 }, async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Span', spans: expect.arrayContaining([ @@ -136,14 +136,14 @@ describe('redis cache auto instrumentation', () => { ]), }; - await createRunner(__dirname, 'scenario-ioredis.js') + await createRunner({ signal }, __dirname, 'scenario-ioredis.js') .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port=6379'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); }); - test('should create cache spans for prefixed keys (redis-4)', async () => { + test('should create cache spans for prefixed keys (redis-4)', async ({ signal }) => { const EXPECTED_REDIS_CONNECT = { transaction: 'redis-connect', }; @@ -227,7 +227,7 @@ describe('redis cache auto instrumentation', () => { ]), }; - await createRunner(__dirname, 'scenario-redis-4.js') + await createRunner({ signal }, __dirname, 'scenario-redis-4.js') .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port=6379'] }) .expect({ transaction: EXPECTED_REDIS_CONNECT }) .expect({ transaction: EXPECTED_TRANSACTION }) diff --git a/dev-packages/node-integration-tests/suites/tracing/redis/test.ts b/dev-packages/node-integration-tests/suites/tracing/redis/test.ts index ec9cc0d93e84..17fa75376db3 100644 --- a/dev-packages/node-integration-tests/suites/tracing/redis/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/redis/test.ts @@ -9,7 +9,7 @@ describe('redis auto instrumentation', () => { test( 'should auto-instrument `ioredis` package when using redis.set() and redis.get()', { timeout: 75_000 }, - async () => { + async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Span', spans: expect.arrayContaining([ @@ -42,7 +42,7 @@ describe('redis auto instrumentation', () => { ]), }; - await createRunner(__dirname, 'scenario-ioredis.js') + await createRunner({ signal }, __dirname, 'scenario-ioredis.js') .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port=6379'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-breadcrumbs/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-breadcrumbs/test.ts index d3315ae86ece..38d899f9e7ff 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-breadcrumbs/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-breadcrumbs/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing fetch', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing fetch requests create breadcrumbs', async () => { - const [SERVER_URL, closeTestServer] = await createTestServer().start(); + test('outgoing fetch requests create breadcrumbs', async ({ signal }) => { + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }).start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing-no-spans/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing-no-spans/test.ts index f61532d9de8b..a92cf6464930 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing-no-spans/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing-no-spans/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing fetch', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing fetch requests are correctly instrumented with tracing & spans are disabled', async () => { + test('outgoing fetch requests are correctly instrumented with tracing & spans are disabled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); @@ -28,7 +28,7 @@ describe('outgoing fetch', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts index b4594c4d9c41..a59376297606 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing fetch', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing fetch requests are correctly instrumented with tracing disabled', async () => { + test('outgoing fetch requests are correctly instrumented with tracing disabled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); @@ -28,7 +28,7 @@ describe('outgoing fetch', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts index 32f24517b3f6..4ed95689f652 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing fetch', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing sampled fetch requests without active span are correctly instrumented', async () => { + test('outgoing sampled fetch requests without active span are correctly instrumented', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); @@ -28,7 +28,7 @@ describe('outgoing fetch', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts index 097236ba4e7f..845a6ef8a940 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing fetch', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing fetch requests are correctly instrumented when not sampled', async () => { + test('outgoing fetch requests are correctly instrumented when not sampled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); @@ -28,7 +28,7 @@ describe('outgoing fetch', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-breadcrumbs/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-breadcrumbs/test.ts index 318d4628453b..198673b792c6 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-breadcrumbs/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-breadcrumbs/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing http requests create breadcrumbs', async () => { - const [SERVER_URL, closeTestServer] = await createTestServer().start(); + test('outgoing http requests create breadcrumbs', async ({ signal }) => { + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }).start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts index fe9cba032344..a7cf583cb11f 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts @@ -6,10 +6,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http requests with tracing & spans disabled', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { conditionalTest({ min: 22 })('node >=22', () => { - test('outgoing http requests are correctly instrumented with tracing & spans disabled', async () => { + test('outgoing http requests are correctly instrumented with tracing & spans disabled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); @@ -30,7 +30,7 @@ describe('outgoing http requests with tracing & spans disabled', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { @@ -104,10 +104,12 @@ describe('outgoing http requests with tracing & spans disabled', () => { // On older node versions, outgoing requests do not get trace-headers injected, sadly // This is because the necessary diagnostics channel hook is not available yet conditionalTest({ max: 21 })('node <22', () => { - test('outgoing http requests generate breadcrumbs correctly with tracing & spans disabled', async () => { + test('outgoing http requests generate breadcrumbs correctly with tracing & spans disabled', async ({ + signal, + }) => { expect.assertions(9); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { // This is not instrumented, sadly expect(headers['baggage']).toBeUndefined(); @@ -128,7 +130,7 @@ describe('outgoing http requests with tracing & spans disabled', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing/test.ts index 7922fe3a443f..daa5c35c7988 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing http requests are correctly instrumented with tracing disabled', async () => { + test('outgoing http requests are correctly instrumented with tracing disabled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); @@ -28,7 +28,7 @@ describe('outgoing http', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts index 8d1afff8c867..73efe31a3729 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing sampled http requests without active span are correctly instrumented', async () => { + test('outgoing sampled http requests without active span are correctly instrumented', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); @@ -28,7 +28,7 @@ describe('outgoing http', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/test.ts index 5951db7f51b7..2e6007001499 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing sampled http requests are correctly instrumented', async () => { + test('outgoing sampled http requests are correctly instrumented', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); @@ -28,7 +28,7 @@ describe('outgoing http', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ transaction: { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-unsampled/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-unsampled/test.ts index 4e83d2e3feb1..da912677bc81 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-unsampled/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-unsampled/test.ts @@ -4,10 +4,10 @@ import { createTestServer } from '../../../../utils/server'; describe('outgoing http', () => { createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('outgoing http requests are correctly instrumented when not sampled', async () => { + test('outgoing http requests are correctly instrumented when not sampled', async ({ signal }) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); @@ -28,7 +28,7 @@ describe('outgoing http', () => { }) .start(); - await createRunner() + await createRunner({ signal }) .withEnv({ SERVER_URL }) .expect({ event: { diff --git a/dev-packages/node-integration-tests/suites/tracing/sample-rand-propagation/test.ts b/dev-packages/node-integration-tests/suites/tracing/sample-rand-propagation/test.ts index df25a261ab2c..616a1b50a266 100644 --- a/dev-packages/node-integration-tests/suites/tracing/sample-rand-propagation/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/sample-rand-propagation/test.ts @@ -6,8 +6,8 @@ describe('sample_rand propagation', () => { cleanupChildProcesses(); }); - test('propagates a sample rand when there are no incoming trace headers', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('propagates a sample rand when there are no incoming trace headers', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check'); expect(response).toEqual({ propagatedData: { @@ -16,8 +16,10 @@ describe('sample_rand propagation', () => { }); }); - test('propagates a sample rand when there is a sentry-trace header and incoming sentry baggage', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('propagates a sample rand when there is a sentry-trace header and incoming sentry baggage', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-1', @@ -31,8 +33,10 @@ describe('sample_rand propagation', () => { }); }); - test('propagates a sample rand when there is an incoming sentry-trace header but no baggage header', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('propagates a sample rand when there is an incoming sentry-trace header but no baggage header', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-1', @@ -45,8 +49,10 @@ describe('sample_rand propagation', () => { }); }); - test('propagates a sample_rand that would lead to a positive sampling decision when there is an incoming positive sampling decision but no sample_rand in the baggage header', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('propagates a sample_rand that would lead to a positive sampling decision when there is an incoming positive sampling decision but no sample_rand in the baggage header', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-1', @@ -62,8 +68,10 @@ describe('sample_rand propagation', () => { expect(sampleRand).toBeGreaterThanOrEqual(0); }); - test('propagates a sample_rand that would lead to a negative sampling decision when there is an incoming negative sampling decision but no sample_rand in the baggage header', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('propagates a sample_rand that would lead to a negative sampling decision when there is an incoming negative sampling decision but no sample_rand in the baggage header', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-0', @@ -79,8 +87,10 @@ describe('sample_rand propagation', () => { expect(sampleRand).toBeLessThan(1); }); - test('a new sample_rand when there is no sentry-trace header but a baggage header with sample_rand', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('a new sample_rand when there is no sentry-trace header but a baggage header with sample_rand', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { baggage: 'sentry-sample_rate=0.75,sentry-sample_rand=0.5', diff --git a/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/no-tracing-enabled/test.ts b/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/no-tracing-enabled/test.ts index b3040dc0cfa4..77adafb4e4e0 100644 --- a/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/no-tracing-enabled/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/no-tracing-enabled/test.ts @@ -6,8 +6,8 @@ describe('parentSampleRate propagation with no tracing enabled', () => { cleanupChildProcesses(); }); - test('should propagate an incoming sample rate', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate an incoming sample rate', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-1', @@ -18,8 +18,8 @@ describe('parentSampleRate propagation with no tracing enabled', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0\.1337/); }); - test('should not propagate a sample rate for root traces', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should not propagate a sample rate for root traces', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check'); expect((response as any).propagatedData.baggage).not.toMatch(/sentry-sample_rate/); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampleRate-0/test.ts b/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampleRate-0/test.ts index 833f04e431a6..4a44469d177a 100644 --- a/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampleRate-0/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampleRate-0/test.ts @@ -6,8 +6,8 @@ describe('parentSampleRate propagation with tracesSampleRate=0', () => { cleanupChildProcesses(); }); - test('should propagate incoming sample rate when inheriting a positive sampling decision', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate incoming sample rate when inheriting a positive sampling decision', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-1', @@ -18,8 +18,8 @@ describe('parentSampleRate propagation with tracesSampleRate=0', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0\.1337/); }); - test('should propagate incoming sample rate when inheriting a negative sampling decision', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate incoming sample rate when inheriting a negative sampling decision', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-0', @@ -30,8 +30,10 @@ describe('parentSampleRate propagation with tracesSampleRate=0', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0\.1337/); }); - test('should propagate configured sample rate when receiving a trace without sampling decision and sample rate', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate configured sample rate when receiving a trace without sampling decision and sample rate', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac', @@ -42,8 +44,10 @@ describe('parentSampleRate propagation with tracesSampleRate=0', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0/); }); - test('should propagate configured sample rate when receiving a trace without sampling decision, but with sample rate', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate configured sample rate when receiving a trace without sampling decision, but with sample rate', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac', @@ -54,8 +58,8 @@ describe('parentSampleRate propagation with tracesSampleRate=0', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0/); }); - test('should propagate configured sample rate when there is no incoming trace', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate configured sample rate when there is no incoming trace', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check'); expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0/); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampleRate/test.ts b/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampleRate/test.ts index 8166c72adcb6..a61a928732f8 100644 --- a/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampleRate/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampleRate/test.ts @@ -6,8 +6,8 @@ describe('parentSampleRate propagation with tracesSampleRate', () => { cleanupChildProcesses(); }); - test('should propagate incoming sample rate when inheriting a positive sampling decision', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate incoming sample rate when inheriting a positive sampling decision', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-1', @@ -18,8 +18,8 @@ describe('parentSampleRate propagation with tracesSampleRate', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0\.1337/); }); - test('should propagate incoming sample rate when inheriting a negative sampling decision', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate incoming sample rate when inheriting a negative sampling decision', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-0', @@ -30,8 +30,10 @@ describe('parentSampleRate propagation with tracesSampleRate', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0\.1337/); }); - test('should propagate configured sample rate when receiving a trace without sampling decision and sample rate', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate configured sample rate when receiving a trace without sampling decision and sample rate', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac', @@ -42,8 +44,10 @@ describe('parentSampleRate propagation with tracesSampleRate', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0\.69/); }); - test('should propagate configured sample rate when receiving a trace without sampling decision, but with sample rate', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate configured sample rate when receiving a trace without sampling decision, but with sample rate', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac', @@ -54,8 +58,8 @@ describe('parentSampleRate propagation with tracesSampleRate', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0\.69/); }); - test('should propagate configured sample rate when there is no incoming trace', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate configured sample rate when there is no incoming trace', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check'); expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0\.69/); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampler/test.ts b/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampler/test.ts index c50e37c87780..5ec49f0aee22 100644 --- a/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampler/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/sample-rate-propagation/tracesSampler/test.ts @@ -6,14 +6,18 @@ describe('parentSampleRate propagation with tracesSampler', () => { cleanupChildProcesses(); }); - test('should propagate sample_rate equivalent to sample rate returned by tracesSampler when there is no incoming trace', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate sample_rate equivalent to sample rate returned by tracesSampler when there is no incoming trace', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check'); expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0\.69/); }); - test('should propagate sample_rate equivalent to sample rate returned by tracesSampler when there is no incoming sample rate (1 -> because there is a positive sampling decision and inheritOrSampleWith was used)', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate sample_rate equivalent to sample rate returned by tracesSampler when there is no incoming sample rate (1 -> because there is a positive sampling decision and inheritOrSampleWith was used)', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-1', @@ -24,8 +28,10 @@ describe('parentSampleRate propagation with tracesSampler', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=1/); }); - test('should propagate sample_rate equivalent to sample rate returned by tracesSampler when there is no incoming sample rate (0 -> because there is a negative sampling decision and inheritOrSampleWith was used)', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate sample_rate equivalent to sample rate returned by tracesSampler when there is no incoming sample rate (0 -> because there is a negative sampling decision and inheritOrSampleWith was used)', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-0', @@ -36,8 +42,10 @@ describe('parentSampleRate propagation with tracesSampler', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0/); }); - test('should propagate sample_rate equivalent to sample rate returned by tracesSampler when there is no incoming sample rate (the fallback value -> because there is no sampling decision and inheritOrSampleWith was used)', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate sample_rate equivalent to sample rate returned by tracesSampler when there is no incoming sample rate (the fallback value -> because there is no sampling decision and inheritOrSampleWith was used)', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac', @@ -48,8 +56,10 @@ describe('parentSampleRate propagation with tracesSampler', () => { expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rate=0\.69/); }); - test('should propagate sample_rate equivalent to incoming sample_rate (because tracesSampler is configured that way)', async () => { - const runner = createRunner(__dirname, 'server.js').start(); + test('should propagate sample_rate equivalent to incoming sample_rate (because tracesSampler is configured that way)', async ({ + signal, + }) => { + const runner = createRunner({ signal }, __dirname, 'server.js').start(); const response = await runner.makeRequest('get', '/check', { headers: { 'sentry-trace': '530699e319cc067ce440315d74acb312-414dc2a08d5d1dac-1', diff --git a/dev-packages/node-integration-tests/suites/tracing/tedious/test.ts b/dev-packages/node-integration-tests/suites/tracing/tedious/test.ts index 9a9fa28b1022..352b8de33ce7 100644 --- a/dev-packages/node-integration-tests/suites/tracing/tedious/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/tedious/test.ts @@ -7,7 +7,7 @@ describe.skip('tedious auto instrumentation', { timeout: 75_000 }, () => { cleanupChildProcesses(); }); - test('should auto-instrument `tedious` package', async () => { + test('should auto-instrument `tedious` package', async ({ signal }) => { const EXPECTED_TRANSACTION = { transaction: 'Test Transaction', spans: expect.arrayContaining([ @@ -42,7 +42,7 @@ describe.skip('tedious auto instrumentation', { timeout: 75_000 }, () => { ]), }; - await createRunner(__dirname, 'scenario.js') + await createRunner({ signal }, __dirname, 'scenario.js') .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['1433'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() diff --git a/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/baggage-org-id/test.ts b/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/baggage-org-id/test.ts index 732473ac4880..e5e797ebc0f5 100644 --- a/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/baggage-org-id/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/baggage-org-id/test.ts @@ -6,8 +6,8 @@ afterAll(() => { cleanupChildProcesses(); }); -test('should include explicitly set org_id in the baggage header', async () => { - const runner = createRunner(__dirname, 'server.ts').start(); +test('should include explicitly set org_id in the baggage header', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server.ts').start(); const response = await runner.makeRequest('get', '/test/express'); expect(response).toBeDefined(); @@ -16,8 +16,8 @@ test('should include explicitly set org_id in the baggage header', async () => { expect(baggage).toContain('sentry-org_id=01234987'); }); -test('should extract org_id from DSN host when not explicitly set', async () => { - const runner = createRunner(__dirname, 'server-no-explicit-org-id.ts').start(); +test('should extract org_id from DSN host when not explicitly set', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server-no-explicit-org-id.ts').start(); const response = await runner.makeRequest('get', '/test/express'); expect(response).toBeDefined(); @@ -26,8 +26,8 @@ test('should extract org_id from DSN host when not explicitly set', async () => expect(baggage).toContain('sentry-org_id=01234987'); }); -test('should set undefined org_id when it cannot be extracted', async () => { - const runner = createRunner(__dirname, 'server-no-org-id.ts').start(); +test('should set undefined org_id when it cannot be extracted', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'server-no-org-id.ts').start(); const response = await runner.makeRequest('get', '/test/express'); expect(response).toBeDefined(); diff --git a/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/test.ts b/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/test.ts index 4185dec46afb..55ad35ccb649 100644 --- a/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/test.ts @@ -2,10 +2,12 @@ import { expect, test } from 'vitest'; import { createRunner } from '../../../utils/runner'; import { createTestServer } from '../../../utils/server'; -test('HttpIntegration should instrument correct requests when tracePropagationTargets option is provided', async () => { +test('HttpIntegration should instrument correct requests when tracePropagationTargets option is provided', async ({ + signal, +}) => { expect.assertions(11); - const [SERVER_URL, closeTestServer] = await createTestServer() + const [SERVER_URL, closeTestServer] = await createTestServer({ signal }) .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); @@ -26,7 +28,7 @@ test('HttpIntegration should instrument correct requests when tracePropagationTa }) .start(); - await createRunner(__dirname, 'scenario.ts') + await createRunner({ signal }, __dirname, 'scenario.ts') .withEnv({ SERVER_URL }) .expect({ transaction: { diff --git a/dev-packages/node-integration-tests/suites/tracing/vercelai/test.ts b/dev-packages/node-integration-tests/suites/tracing/vercelai/test.ts index 94fd0dde8486..f88831b4029d 100644 --- a/dev-packages/node-integration-tests/suites/tracing/vercelai/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/vercelai/test.ts @@ -406,19 +406,22 @@ describe('Vercel AI integration', () => { }; createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('creates ai related spans with sendDefaultPii: false', async () => { - await createRunner().expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }).start().completed(); + test('creates ai related spans with sendDefaultPii: false', async ({ signal }) => { + await createRunner({ signal }) + .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }) + .start() + .completed(); }); }); createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('creates ai related spans with sendDefaultPii: true', async () => { - await createRunner().expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_TRUE }).start().completed(); + test('creates ai related spans with sendDefaultPii: true', async ({ signal }) => { + await createRunner({ signal }).expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_TRUE }).start().completed(); }); }); createEsmAndCjsTests(__dirname, 'scenario-error-in-tool.mjs', 'instrument.mjs', (createRunner, test) => { - test('captures error in tool', async () => { + test('captures error in tool', async ({ signal }) => { const expectedTransaction = { transaction: 'main', spans: expect.arrayContaining([ @@ -518,7 +521,7 @@ describe('Vercel AI integration', () => { }, }; - await createRunner() + await createRunner({ signal }) .expect({ transaction: transaction => { expect(transaction).toMatchObject(expectedTransaction); @@ -539,7 +542,7 @@ describe('Vercel AI integration', () => { }); createEsmAndCjsTests(__dirname, 'scenario-error-in-tool-express.mjs', 'instrument.mjs', (createRunner, test) => { - test('captures error in tool in express server', async () => { + test('captures error in tool in express server', async ({ signal }) => { const expectedTransaction = { transaction: 'GET /test/error-in-tool', spans: expect.arrayContaining([ @@ -639,7 +642,7 @@ describe('Vercel AI integration', () => { let transactionEvent: Event | undefined; let errorEvent: Event | undefined; - const runner = await createRunner() + const runner = await createRunner({ signal }) .expect({ transaction: transaction => { transactionEvent = transaction; diff --git a/dev-packages/node-integration-tests/suites/tracing/vercelai/v5/test.ts b/dev-packages/node-integration-tests/suites/tracing/vercelai/v5/test.ts index 2b697bfedbdb..ca284171107a 100644 --- a/dev-packages/node-integration-tests/suites/tracing/vercelai/v5/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/vercelai/v5/test.ts @@ -400,8 +400,11 @@ describe('Vercel AI integration (V5)', () => { 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('creates ai related spans with sendDefaultPii: false', async () => { - await createRunner().expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }).start().completed(); + test('creates ai related spans with sendDefaultPii: false', async ({ signal }) => { + await createRunner({ signal }) + .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }) + .start() + .completed(); }); }, { @@ -416,8 +419,11 @@ describe('Vercel AI integration (V5)', () => { 'scenario.mjs', 'instrument-with-pii.mjs', (createRunner, test) => { - test('creates ai related spans with sendDefaultPii: true', async () => { - await createRunner().expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_TRUE }).start().completed(); + test('creates ai related spans with sendDefaultPii: true', async ({ signal }) => { + await createRunner({ signal }) + .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_TRUE }) + .start() + .completed(); }); }, { @@ -432,7 +438,7 @@ describe('Vercel AI integration (V5)', () => { 'scenario-error-in-tool.mjs', 'instrument.mjs', (createRunner, test) => { - test('captures error in tool', async () => { + test('captures error in tool', async ({ signal }) => { const expectedTransaction = { transaction: 'main', spans: expect.arrayContaining([ @@ -515,7 +521,7 @@ describe('Vercel AI integration (V5)', () => { let transactionEvent: Event | undefined; let errorEvent: Event | undefined; - await createRunner() + await createRunner({ signal }) .expect({ transaction: transaction => { transactionEvent = transaction; @@ -551,8 +557,11 @@ describe('Vercel AI integration (V5)', () => { 'scenario.mjs', 'instrument.mjs', (createRunner, test) => { - test('creates ai related spans with v5', async () => { - await createRunner().expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }).start().completed(); + test('creates ai related spans with v5', async ({ signal }) => { + await createRunner({ signal }) + .expect({ transaction: EXPECTED_TRANSACTION_DEFAULT_PII_FALSE }) + .start() + .completed(); }); }, { diff --git a/dev-packages/node-integration-tests/suites/winston/test.ts b/dev-packages/node-integration-tests/suites/winston/test.ts index 034210f8690b..c6f323cf441b 100644 --- a/dev-packages/node-integration-tests/suites/winston/test.ts +++ b/dev-packages/node-integration-tests/suites/winston/test.ts @@ -6,8 +6,8 @@ describe('winston integration', () => { cleanupChildProcesses(); }); - test('should capture winston logs with default levels', async () => { - const runner = createRunner(__dirname, 'subject.ts') + test('should capture winston logs with default levels', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'subject.ts') .expect({ log: { items: [ @@ -49,8 +49,8 @@ describe('winston integration', () => { await runner.completed(); }); - test('should capture winston logs with custom levels', async () => { - const runner = createRunner(__dirname, 'subject.ts') + test('should capture winston logs with custom levels', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'subject.ts') .withEnv({ CUSTOM_LEVELS: 'true' }) .expect({ log: { @@ -123,8 +123,8 @@ describe('winston integration', () => { await runner.completed(); }); - test('should capture winston logs with metadata', async () => { - const runner = createRunner(__dirname, 'subject.ts') + test('should capture winston logs with metadata', async ({ signal }) => { + const runner = createRunner({ signal }, __dirname, 'subject.ts') .withEnv({ WITH_METADATA: 'true' }) .expect({ log: { diff --git a/dev-packages/node-integration-tests/utils/runner.ts b/dev-packages/node-integration-tests/utils/runner.ts index b0c6467fd75a..d89f7d565753 100644 --- a/dev-packages/node-integration-tests/utils/runner.ts +++ b/dev-packages/node-integration-tests/utils/runner.ts @@ -70,6 +70,11 @@ interface DockerOptions { * The command to run after docker compose is up */ setupCommand?: string; + + /** + * An optional AbortSignal to cancel the docker compose up command + */ + signal?: AbortSignal; } /** @@ -90,7 +95,9 @@ async function runDockerCompose(options: DockerOptions): Promise { // ensure we're starting fresh close(); - const child = spawn('docker', ['compose', 'up'], { cwd }); + options.signal?.addEventListener('abort', () => close()); + + const child = spawn('docker', ['compose', 'up'], { cwd, signal: options.signal }); const timeout = setTimeout(() => { close(); @@ -178,7 +185,7 @@ export function createEsmAndCjsTests( scenarioPath: string, instrumentPath: string, callback: ( - createTestRunner: () => ReturnType, + createTestRunner: (options: { readonly signal?: AbortSignal }) => ReturnType, testFn: typeof test | typeof test.fails, mode: 'esm' | 'cjs', cwd: string, @@ -289,7 +296,7 @@ export function createEsmAndCjsTests( const esmTestFn = options?.failsOnEsm ? test.fails : test; describe('esm', () => { callback( - () => createRunner(esmScenarioPathForRun).withFlags('--import', esmInstrumentPathForRun), + ({ signal }) => createRunner({ signal }, esmScenarioPathForRun).withFlags('--import', esmInstrumentPathForRun), esmTestFn, 'esm', tmpDirPath, @@ -299,7 +306,7 @@ export function createEsmAndCjsTests( const cjsTestFn = options?.failsOnCjs ? test.fails : test; describe('cjs', () => { callback( - () => createRunner(cjsScenarioPath).withFlags('--require', cjsInstrumentPath), + ({ signal }) => createRunner({ signal }, cjsScenarioPath).withFlags('--require', cjsInstrumentPath), cjsTestFn, 'cjs', tmpDirPath, @@ -336,7 +343,7 @@ async function convertEsmFileToCjs(inputPath: string, outputPath: string): Promi /** Creates a test runner */ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type -export function createRunner(...paths: string[]) { +export function createRunner({ signal }: { readonly signal?: AbortSignal }, ...paths: string[]) { const testPath = join(...paths); if (!existsSync(testPath)) { @@ -406,7 +413,7 @@ export function createRunner(...paths: string[]) { } return this; }, - withDockerCompose: function (options: DockerOptions) { + withDockerCompose: function (options: Omit) { dockerOptions = options; return this; }, @@ -531,11 +538,11 @@ export function createRunner(...paths: string[]) { type DockerStartup = VoidFunction | undefined; const serverStartup: Promise = withSentryServer - ? createBasicSentryServer(newEnvelope) + ? createBasicSentryServer(newEnvelope, { signal }) : Promise.resolve([undefined, undefined]); const dockerStartup: Promise = dockerOptions - ? runDockerCompose(dockerOptions) + ? runDockerCompose({ ...dockerOptions, signal }) : Promise.resolve(undefined); const startup = Promise.all([dockerStartup, serverStartup]); @@ -558,7 +565,7 @@ export function createRunner(...paths: string[]) { if (process.env.DEBUG) log('starting scenario', testPath, flags, env.SENTRY_DSN); - child = spawn('node', [...flags, testPath], { env }); + child = spawn('node', [...flags, testPath], { env, signal }); child.on('error', e => { // eslint-disable-next-line no-console diff --git a/dev-packages/node-integration-tests/utils/server.ts b/dev-packages/node-integration-tests/utils/server.ts index a1ba3f522fb1..41d4829fe62f 100644 --- a/dev-packages/node-integration-tests/utils/server.ts +++ b/dev-packages/node-integration-tests/utils/server.ts @@ -5,7 +5,7 @@ type HeaderAssertCallback = (headers: Record = []; let error: unknown | undefined; @@ -32,6 +32,7 @@ export function createTestServer() { return new Promise(resolve => { const server = app.listen(0, () => { const address = server.address() as AddressInfo; + signal?.addEventListener('abort', () => server.close()); resolve([ `http://localhost:${address.port}`, () => { diff --git a/dev-packages/test-utils/src/server.ts b/dev-packages/test-utils/src/server.ts index b8941b4b0c32..3b624c8cd532 100644 --- a/dev-packages/test-utils/src/server.ts +++ b/dev-packages/test-utils/src/server.ts @@ -9,7 +9,10 @@ import type { AddressInfo } from 'net'; * This does no checks on the envelope, it just calls the callback if it managed to parse an envelope from the raw POST * body data. */ -export function createBasicSentryServer(onEnvelope: (env: Envelope) => void): Promise<[number, () => void]> { +export function createBasicSentryServer( + onEnvelope: (env: Envelope) => void, + { signal }: { readonly signal?: AbortSignal }, +): Promise<[number, () => void]> { const app = express(); app.use(express.raw({ type: () => true, inflate: true, limit: '100mb' })); @@ -27,6 +30,7 @@ export function createBasicSentryServer(onEnvelope: (env: Envelope) => void): Pr return new Promise(resolve => { const server = app.listen(0, () => { + signal?.addEventListener('abort', () => server.close()); const address = server.address() as AddressInfo; resolve([ address.port,