Repository navigation
feat(node): Support postgres v4 through its native tracing channels - #26076
Conversation
size-limit report 📦Compared: e476f47 (PR test merge using develop at f2ee787) Against: f2ee787 (develop) · base run #65001 ✅ Baseline matches: this diff contains only this PR's changes.
|
Optional E2E testsSome optional checks were not successful. They do not block the merge. 2 not successful, 53 successful. See the run.
Successful checks
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 50402f8. Configure here.
| @@ -0,0 +1,39 @@ | |||
| import * as Sentry from '@sentry/node'; | |||
There was a problem hiding this comment.
i think this does not need a dedicated scenario, we can just use scenario.mjs here?
mydea
left a comment
There was a problem hiding this comment.
we can maybe clean up some of the test scenarios if they are redundant, but other than this seems good 👍
postgres@4 publishes `postgres:query` on node:diagnostics_channel itself, so postgresJsIntegration now subscribes to it directly. The orchestrion transform stays gated to 3.x.
50402f8 to
e818de3
Compare
postgres v4 rewrote everything below its public API, including the internals that Sentry's code injection hooked into, so v4 queries got no spans and we held off on the bump. Sentry 11.11 traces v4 through the tracing channels it now publishes (getsentry/sentry-javascript#26076), so `@compas/store` accepts both v3 and v4. - The range is `^3.4.9 || ^4.1.1`. An app that depends on `postgres@^3` itself keeps v3, since that copy satisfies the range. The suite passes on both. - v4 lets the server decide parameter types. Compas's own queries don't notice: generated tables use `timestamptz`, date-only and time-only values are strings, and the interval and jsonb updates cast their parameters. - The lazy `postgres` import only matters for v3 now. It can go once we drop v3. - `compasWithSentry` now requires 11.11. With an older Sentry, an app that picks up v4 silently loses its query spans, and I'd rather have it fail on install. Replaces #4195. BREAKING CHANGE: - `@compas/store` supports postgres v4 and installs it unless your app depends on v3 itself. Add `postgres@^3` to your dependencies to stay on v3. v4 lets the server decide the type of each parameter: a `Date` compared with a `timestamp` or `date` column is taken as UTC, and a `Date` where the query doesn't decide the type, as in `date_trunc('day', ${date})`, needs a cast. Pass `infer: true` to `newPostgresConnection` to keep v3's behaviour. See the [postgres upgrade guide](https://github.com/porsager/postgres#upgrading-from-v3) for the other changes, like the removal of `sql.array()`. - Compas requires `@sentry/node` v11.11 or higher, the first version that traces postgres v4 queries. `compasWithSentry` throws on older versions.

postgres@4 dropped the internals our orchestrion transform hooks into, so v4 queries got no spans, fixed by subscribing to the
postgres:querytracing channel it now publishes natively.I added a v4 integration suite that asserts the same span tree as the v3 one, including the URL, unsafe, requestHook and
instrumentPostgresJsSqldouble-span cases.