Skip to content

Commit 96ef6a3

Browse files
JPeer264claude
andcommitted
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 <noreply@anthropic.com>
1 parent 5f72df5 commit 96ef6a3

File tree

1 file changed

+8
-8
lines changed
  • dev-packages/node-integration-tests/suites/tracing/postgresjs

1 file changed

+8
-8
lines changed

dev-packages/node-integration-tests/suites/tracing/postgresjs/test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ describe('postgresjs auto instrumentation', () => {
218218
};
219219

220220
await createRunner(__dirname, 'scenario.js')
221-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
221+
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] })
222222
.expect({ transaction: EXPECTED_TRANSACTION })
223223
.expect({ event: EXPECTED_ERROR_EVENT })
224224
.start()
@@ -438,7 +438,7 @@ describe('postgresjs auto instrumentation', () => {
438438

439439
await createRunner(__dirname, 'scenario.mjs')
440440
.withFlags('--import', `${__dirname}/instrument.mjs`)
441-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
441+
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] })
442442
.expect({ transaction: EXPECTED_TRANSACTION })
443443
.expect({ event: EXPECTED_ERROR_EVENT })
444444
.start()
@@ -532,7 +532,7 @@ describe('postgresjs auto instrumentation', () => {
532532

533533
await createRunner(__dirname, 'scenario-requestHook.js')
534534
.withFlags('--require', `${__dirname}/instrument-requestHook.cjs`)
535-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
535+
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] })
536536
.expect({ transaction: EXPECTED_TRANSACTION })
537537
.start()
538538
.completed();
@@ -625,7 +625,7 @@ describe('postgresjs auto instrumentation', () => {
625625

626626
await createRunner(__dirname, 'scenario-requestHook.mjs')
627627
.withFlags('--import', `${__dirname}/instrument-requestHook.mjs`)
628-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
628+
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] })
629629
.expect({ transaction: EXPECTED_TRANSACTION })
630630
.start()
631631
.completed();
@@ -706,7 +706,7 @@ describe('postgresjs auto instrumentation', () => {
706706
};
707707

708708
await createRunner(__dirname, 'scenario-url.cjs')
709-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
709+
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] })
710710
.expect({ transaction: EXPECTED_TRANSACTION })
711711
.start()
712712
.completed();
@@ -787,7 +787,7 @@ describe('postgresjs auto instrumentation', () => {
787787

788788
await createRunner(__dirname, 'scenario-url.mjs')
789789
.withFlags('--import', `${__dirname}/instrument.mjs`)
790-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
790+
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] })
791791
.expect({ transaction: EXPECTED_TRANSACTION })
792792
.start()
793793
.completed();
@@ -866,7 +866,7 @@ describe('postgresjs auto instrumentation', () => {
866866
};
867867

868868
await createRunner(__dirname, 'scenario-unsafe.cjs')
869-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
869+
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] })
870870
.expect({ transaction: EXPECTED_TRANSACTION })
871871
.start()
872872
.completed();
@@ -946,7 +946,7 @@ describe('postgresjs auto instrumentation', () => {
946946

947947
await createRunner(__dirname, 'scenario-unsafe.mjs')
948948
.withFlags('--import', `${__dirname}/instrument.mjs`)
949-
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
949+
.withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['database system is ready to accept connections'] })
950950
.expect({ transaction: EXPECTED_TRANSACTION })
951951
.start()
952952
.completed();

0 commit comments

Comments
 (0)