test(node): Fix flaky postgresjs integration test#20351
Open
test(node): Fix flaky postgresjs integration test#20351
Conversation
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>
f9fbd1d to
96ef6a3
Compare
nicohrubec
approved these changes
Apr 16, 2026
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 96ef6a3. Configure here.
Contributor
size-limit report 📦
|
s1gr1d
approved these changes
Apr 20, 2026
Use a docker-compose healthcheck + ready-gate sidecar so readiness is gated on pg_isready succeeding inside the db container. The previous match on 'database system is ready to accept connections' fired on the initdb bootstrap postmaster and raced with its shutdown, causing ECONNRESET on CI under load. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

While releasing a new SDK version I've seen a flaky integration test: https://github.com/getsentry/sentry-javascript/actions/runs/24508519594/job/71634188547?pr=20348
The error actually showed
"db.response.status_code": "57P03",which means that the DB is not yet ready: https://www.postgresql.org/docs/current/errcodes-appendix.htmlHope this fixes it. Addition from Claude:
The test was flaky because it used
readyMatches: ['port 5432']to detectwhen 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.