From 96ef6a349ff23feaf39ee72419095f5ce971b77b Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Thu, 16 Apr 2026 15:20:35 +0200 Subject: [PATCH 1/2] test(node): Fix flaky postgresjs integration test The test was flaky because it used `readyMatches: ['port 5432']` to detect when PostgreSQL was ready. However, PostgreSQL logs "port 5432" when it starts listening, but before it's fully ready to accept connections. On CI runners under load, the gap between binding to the port and being ready to serve queries was long enough that tests sometimes received PostgreSQL error 57P03 ("cannot_connect_now") because the database was still initializing. Changed to wait for "database system is ready to accept connections" which PostgreSQL logs when it's actually ready to serve queries. Co-Authored-By: Claude Opus 4.5 --- .../suites/tracing/postgresjs/test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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 2dfbc020966b..9a376750368b 100644 --- a/dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts @@ -218,7 +218,7 @@ describe('postgresjs auto instrumentation', () => { }; await createRunner(__dirname, 'scenario.js') - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] }) + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .expect({ event: EXPECTED_ERROR_EVENT }) .start() @@ -438,7 +438,7 @@ describe('postgresjs auto instrumentation', () => { await createRunner(__dirname, 'scenario.mjs') .withFlags('--import', `${__dirname}/instrument.mjs`) - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] }) + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .expect({ event: EXPECTED_ERROR_EVENT }) .start() @@ -532,7 +532,7 @@ describe('postgresjs auto instrumentation', () => { await createRunner(__dirname, 'scenario-requestHook.js') .withFlags('--require', `${__dirname}/instrument-requestHook.cjs`) - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] }) + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); @@ -625,7 +625,7 @@ describe('postgresjs auto instrumentation', () => { await createRunner(__dirname, 'scenario-requestHook.mjs') .withFlags('--import', `${__dirname}/instrument-requestHook.mjs`) - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] }) + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); @@ -706,7 +706,7 @@ describe('postgresjs auto instrumentation', () => { }; await createRunner(__dirname, 'scenario-url.cjs') - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] }) + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); @@ -787,7 +787,7 @@ describe('postgresjs auto instrumentation', () => { await createRunner(__dirname, 'scenario-url.mjs') .withFlags('--import', `${__dirname}/instrument.mjs`) - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] }) + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); @@ -866,7 +866,7 @@ describe('postgresjs auto instrumentation', () => { }; await createRunner(__dirname, 'scenario-unsafe.cjs') - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] }) + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); @@ -946,7 +946,7 @@ describe('postgresjs auto instrumentation', () => { await createRunner(__dirname, 'scenario-unsafe.mjs') .withFlags('--import', `${__dirname}/instrument.mjs`) - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] }) + .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); From 7f4db7817052488dd263f7b7b98880bfe5db42c8 Mon Sep 17 00:00:00 2001 From: JPeer264 Date: Thu, 16 Apr 2026 18:40:17 +0200 Subject: [PATCH 2/2] fixup! test(node): Fix flaky postgresjs integration test --- .../suites/tracing/postgresjs/test.ts | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) 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 9a376750368b..cd4742000a85 100644 --- a/dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts @@ -218,7 +218,10 @@ describe('postgresjs auto instrumentation', () => { }; await createRunner(__dirname, 'scenario.js') - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) + .withDockerCompose({ + workingDirectory: [__dirname], + readyMatches: ['database system is ready to accept connections'], + }) .expect({ transaction: EXPECTED_TRANSACTION }) .expect({ event: EXPECTED_ERROR_EVENT }) .start() @@ -438,7 +441,10 @@ describe('postgresjs auto instrumentation', () => { await createRunner(__dirname, 'scenario.mjs') .withFlags('--import', `${__dirname}/instrument.mjs`) - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) + .withDockerCompose({ + workingDirectory: [__dirname], + readyMatches: ['database system is ready to accept connections'], + }) .expect({ transaction: EXPECTED_TRANSACTION }) .expect({ event: EXPECTED_ERROR_EVENT }) .start() @@ -532,7 +538,10 @@ describe('postgresjs auto instrumentation', () => { await createRunner(__dirname, 'scenario-requestHook.js') .withFlags('--require', `${__dirname}/instrument-requestHook.cjs`) - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) + .withDockerCompose({ + workingDirectory: [__dirname], + readyMatches: ['database system is ready to accept connections'], + }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); @@ -625,7 +634,10 @@ describe('postgresjs auto instrumentation', () => { await createRunner(__dirname, 'scenario-requestHook.mjs') .withFlags('--import', `${__dirname}/instrument-requestHook.mjs`) - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) + .withDockerCompose({ + workingDirectory: [__dirname], + readyMatches: ['database system is ready to accept connections'], + }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); @@ -706,7 +718,10 @@ describe('postgresjs auto instrumentation', () => { }; await createRunner(__dirname, 'scenario-url.cjs') - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) + .withDockerCompose({ + workingDirectory: [__dirname], + readyMatches: ['database system is ready to accept connections'], + }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); @@ -787,7 +802,10 @@ describe('postgresjs auto instrumentation', () => { await createRunner(__dirname, 'scenario-url.mjs') .withFlags('--import', `${__dirname}/instrument.mjs`) - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) + .withDockerCompose({ + workingDirectory: [__dirname], + readyMatches: ['database system is ready to accept connections'], + }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); @@ -866,7 +884,10 @@ describe('postgresjs auto instrumentation', () => { }; await createRunner(__dirname, 'scenario-unsafe.cjs') - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) + .withDockerCompose({ + workingDirectory: [__dirname], + readyMatches: ['database system is ready to accept connections'], + }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed(); @@ -946,7 +967,10 @@ describe('postgresjs auto instrumentation', () => { await createRunner(__dirname, 'scenario-unsafe.mjs') .withFlags('--import', `${__dirname}/instrument.mjs`) - .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] }) + .withDockerCompose({ + workingDirectory: [__dirname], + readyMatches: ['database system is ready to accept connections'], + }) .expect({ transaction: EXPECTED_TRANSACTION }) .start() .completed();