Skip to content

Add diagnostics_channel TracingChannel support - #32

Closed
MiichelleZhou wants to merge 7 commits into
eval/3650/basefrom
eval/3650/qodo/round-7
Closed

MiichelleZhou wants to merge 7 commits into
eval/3650/basefrom
eval/3650/qodo/round-7

Conversation

@MiichelleZhou

@MiichelleZhou MiichelleZhou commented Sep 28, 2026 •

Copy link
Copy Markdown

This PR introduces tracing channels support to pg-pool and pg querying methods as discussed in #3619

I haven't yet run a benchmark, but without active tracing or subscribers the overhead is non-existent so existing users shouldn't be affected. The overhead would come from the consumers of the diag channels published here which is done anyways via monkey patching.

I added the following channels:

Channel Type Package Description
pg:query TracingChannel pg Query lifecycle (start, end, error with async context)
pg:connection TracingChannel pg Client connection lifecycle
pg:pool:connect TracingChannel pg-pool Pool connection acquisition lifecycle
pg:pool:release Channel pg-pool Client released back to pool
pg:pool:remove Channel pg-pool Client removed from pool

I understand there may be hesitation given that AI tooling was used in the implementation. To be clear, this isn't a drive-by contribution. I designed the channel layout, wrote the proposal document, and iterated through multiple rounds to handle real edge cases (Node 18 compat, preserving custom Promise types, hasSubscribers guards). The AI assisted with the code, but the approach and decisions are mine.

Usage

Instrumentations will only need to subscribe to tracing channels to create traces, logs or metrics:

import { tracingChannel } from 'diagnostics_channel'

tracingChannel('pg:query').subscribe({
  start({ query, client }) {
    // start span
    // query: { text, name, rowMode }
    // client: { database, host, port, user, processID, ssl }
  },
  asyncEnd({ query, result }) {
    // end span
    // result: { rowCount, command }
  },
  error({ query, error }) {
    // record error on span
  },
})

This is part of a broader initiative to bring TracingChannel support to the most widely used Node.js database and cache libraries. The same pattern has already been merged and shipped in:

I have been directly involved in those prior implementations and I'm happy to own this through to release, address any feedback, and provide whatever support is needed. Would love to hear your thoughts.

Supersedes #3624.


Devin Review


Note

Medium Risk
Instrumentation wraps core connect and query checkout paths; behavior should be unchanged without subscribers, but callback wrapping and Node 18 tracing fallbacks warrant careful review.

Overview
Adds first-class Node.js diagnostics_channel instrumentation to pg and pg-pool, so APM/tracing tools can subscribe without monkey-patching.

pg exposes TracingChannel hooks on pg:connection (Client.connect) and pg:query (callback-based Client.query), publishing connection/query metadata and enriching async context with results (rowCount, command). pg-pool adds pg:pool:connect (checkout lifecycle with pool stats and client processID / reuse), plus pg:pool:release and pg:pool:remove publish channels on release and removal.

Shared diagnostics.js helpers load channels via getBuiltInModule / require, fall back to no-op channels when unavailable, and use shouldTrace (hasSubscribers !== false) so Node 18 still traces when the aggregated getter is missing. Unit tests cover channel payloads and skip unstable TracingChannel behavior on older Node versions.

Reviewed by Cursor Bugbot for commit b922f0d. Configure here.

logaretm and others added 7 commits March 5, 2026 12:40
Enables instrumentation libraries (OpenTelemetry, etc.) to subscribe to
structured events without monkey-patching. Uses TracingChannel for async
context propagation and plain channels for simple events.

Channels:
- pg:query (TracingChannel) — query lifecycle with result enrichment
- pg:connection (TracingChannel) — client connect lifecycle
- pg:pool:connect (TracingChannel) — pool checkout lifecycle
- pg:pool:release (plain) — client released back to pool
- pg:pool:remove (plain) — client removed from pool

All instrumentation is guarded by hasSubscribers for zero overhead when
unused. Gracefully degrades to no-ops on Node < 19.9 or non-Node
environments.

Closes #3619

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
TracingChannel is not available on Node 18 LTS. Skip the tracing-dependent
tests gracefully instead of failing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Node 18 backported TracingChannel but without the aggregated
`hasSubscribers` getter (it returns `undefined` instead of a boolean).
Raw truthiness checks treat `undefined` as "no subscribers" which
silently disables tracing on Node 18.

Replace all `channel.hasSubscribers` guards with `shouldTrace(channel)`
which checks `hasSubscribers !== false` — treating `undefined` (Node 18)
as "might have subscribers, trace unconditionally" and `false` (Node 20+)
as "definitely no subscribers, skip".

Also removes the now-unnecessary test skip logic since TracingChannel
does exist on Node 18.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Node 18 backported TracingChannel but with a buggy implementation —
unsubscribing and resubscribing to the same channel crashes internally
(`_subscribers` becomes undefined). Node 16 has no TracingChannel at all.

Gate tests on `hasStableTracingChannel` which checks both that
`dc.tracingChannel` exists AND that the aggregated `hasSubscribers`
getter returns a boolean (only true on Node 19.9+/20.5+).

TracingChannel tests: skipped on Node 16/18, run on Node 20+
Plain channel tests (release/remove): run on all versions

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…omise type

tracePromise wraps the result in a native Promise, which breaks
clients configured with a custom Promise implementation (e.g. bluebird).
Switch to traceCallback inside the user's this._Promise constructor
so the returned promise type is always correct.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@MiichelleZhou

Copy link
Copy Markdown
Author

/review

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add diagnostics channels for pg queries, connections, and pool lifecycle

✨ Enhancement 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Expose query, connection, and pool lifecycle events for instrumentation without monkey-patching.
• Trace callback and promise operations while avoiding context construction when channels have no
 subscribers.
• Test published events and account for older Node versions with limited TracingChannel support.
Diagram

graph TD
  APP["Application"] --> POOL["pg-pool"] --> CLIENT["pg Client"] --> PGCH["pg channels"] --> DC["Node diagnostics"] --> OBS["Subscribers"]
  POOL --> POOLCH["pool channels"] --> DC
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Instrument existing lifecycle events
  • ➕ Could cover callback-less custom query objects and work without TracingChannel.
  • ➖ Would require consumers to coordinate multiple events and would not provide TracingChannel async context propagation.

Recommendation: Native diagnostics channels are the better fit for structured tracing without monkey-patching. Before release, add diagnostics.js to pg-pool's package files allowlist: it currently lists only index.js and esm, but index.js now requires ./diagnostics.

Files changed (6) +557 / -11

Enhancement (4) +155 / -11
diagnostics.jsDefine pool diagnostics channels and compatibility guard +35/-0

Define pool diagnostics channels and compatibility guard

• Creates a tracing channel for pool acquisition and plain channels for release and removal. Falls back when diagnostics_channel is unavailable and accommodates Node 18's undefined aggregate hasSubscribers value.

packages/pg-pool/diagnostics.js

index.jsPublish pool acquisition, release, and removal diagnostics +34/-0

Publish pool acquisition, release, and removal diagnostics

• Traces pool connect callbacks with pool counts and acquired-client details. Publishes release and removal events with client identifiers, including release errors when present.

packages/pg-pool/index.js

client.jsTrace client connections and queries +55/-11

Trace client connections and queries

• Wraps callback and promise connection paths in connection tracing. Traces queries with query and client metadata, adding result details on completion when a callback is available.

packages/pg/lib/client.js

diagnostics.jsDefine query and connection tracing channels +31/-0

Define query and connection tracing channels

• Initializes pg tracing channels when supported and otherwise uses no-op channel guards. The subscriber check treats Node 18's undefined aggregate hasSubscribers value as potentially subscribed.

packages/pg/lib/diagnostics.js

Tests (2) +402 / -0
diagnostics.jsTest pool diagnostics events +197/-0

Test pool diagnostics events

• Tests acquisition context and release/removal messages using mock clients. Skips tracing-specific cases when the available TracingChannel lacks the expected stable behavior.

packages/pg-pool/test/diagnostics.js

diagnostics-tests.jsTest query and connection trace publication +205/-0

Test query and connection trace publication

• Covers successful and failed queries, promise queries, client metadata, and callback-based connection tracing. Skips these tests where TracingChannel behavior is unavailable or unstable.

packages/pg/test/unit/client/diagnostics-tests.js

@qodo-code-review

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (4) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Published pools fail to load 🐞 Bug ≡ Correctness
Description
pg-pool/index.js now requires ./diagnostics, but the package's files list excludes
diagnostics.js. When pg-pool is installed from a published package, both its CommonJS entry and
ESM wrapper reach that missing module.
Code

packages/pg-pool/index.js[3]

+const { poolConnectChannel, poolReleaseChannel, poolRemoveChannel, shouldTrace } = require('./diagnostics')
Evidence
The new entry-point require targets diagnostics.js, while the explicit publication list contains
only index.js and esm; the ESM wrapper imports that same entry point.

packages/pg-pool/index.js[1-3]
packages/pg-pool/package.json[46-49]
packages/pg-pool/esm/index.mjs[1-5]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The published pg-pool package omits the new module required by its entry point, so imports fail.
## Fix Focus Areas
- packages/pg-pool/package.json[46-49]
- packages/pg-pool/index.js[3-3]
## Recommended Fix
Add `diagnostics.js` to the package's `files` list and verify it appears in a package archive.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Event-based queries escape tracing 🐞 Bug ◔ Observability
Description
Client.query() starts a trace only when query.callback exists, leaving callback-free Query
instances outside the new channel. The supported event-based query API submits those instances and
reports completion through end or error events, so subscribers receive no lifecycle events for
them.
Code

packages/pg/lib/client.js[709]

+    if (shouldTrace(queryChannel) && query.callback) {
Evidence
The client accepts supplied Query instances without assigning a callback, and the integration tests
exercise this supported form with row and end listeners. The added callback guard skips tracing
for those instances.

packages/pg/lib/client.js[622-635]
packages/pg/lib/client.js[703-738]
packages/pg/test/integration/client/simple-query-tests.js[10-30]
packages/pg/lib/query.js[128-149]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Event-based Query instances execute without a callback and therefore produce no query diagnostics.
## Fix Focus Areas
- packages/pg/lib/client.js[622-635]
- packages/pg/lib/client.js[703-738]
- packages/pg/lib/query.js[128-149]
## Recommended Fix
Add tracing for callback-free Query instances using their completion and error events, without changing their event-based API.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Multi-statement traces lose results 🐞 Bug ◔ Observability
Description
enrichedCb reads rowCount and command from res as though it were always one result object.
For a successful multi-statement query, Query passes an array of results, so the published result
metadata has neither statement's command nor row count.
Code

packages/pg/lib/client.js[R722-724]

+      const enrichedCb = (err, res) => {
+        if (res) context.result = { rowCount: res.rowCount, command: res.command }
+        return origCb(err, res)
Evidence
Query._checkForMultirow() converts its results to an array for multiple commands, and completion
passes that array to the callback. The added enrichment reads properties from the array rather than
its elements.

packages/pg/lib/query.js[59-68]
packages/pg/lib/query.js[136-149]
packages/pg/lib/client.js[721-724]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Multi-statement queries return an array, but tracing extracts fields as if the response were one result.
## Fix Focus Areas
- packages/pg/lib/client.js[721-724]
- packages/pg/lib/query.js[59-68]
## Recommended Fix
Handle array results explicitly and publish metadata for each statement while retaining the single-result shape for ordinary queries.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. Query callbacks lose their receiver 🐞 Bug ≡ Correctness
Description
enrichedCb invokes the saved callback as origCb(err, res), discarding the query instance
previously supplied as its receiver. When tracing is subscribed and a query callback uses this, it
no longer sees the Query instance on either success or error.
Code

packages/pg/lib/client.js[R721-724]

+      const origCb = query.callback
+      const enrichedCb = (err, res) => {
+        if (res) context.result = { rowCount: res.rowCount, command: res.command }
+        return origCb(err, res)
Evidence
The existing success and error handlers invoke this.callback(...) on the Query instance. The new
wrapper saves that callback and later calls it as a standalone function.

packages/pg/lib/query.js[128-149]
packages/pg/lib/client.js[721-735]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The tracing wrapper changes the receiver observed by existing query callbacks.
## Fix Focus Areas
- packages/pg/lib/client.js[721-735]
- packages/pg/lib/query.js[128-149]
## Recommended Fix
Use a non-arrow enrichment callback and invoke the saved callback with the receiver supplied to the traced callback, preserving its arguments and return value.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
✅ Web pages:
  +7 more
Review mode: ⚖️ Balanced: Downgraded extended -> standard: change is below the extended eligibility bar (hunks 11/18, lines 568/200; both must reach the floor). Router rationale: This adds substantial behavior across pg and pg-pool query, connection, and pool lifecycles with multiple independent async tracing paths and compatibility concerns, making missed defects plausible across the dense change surface.

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread packages/pg-pool/index.js
@@ -1,5 +1,6 @@
'use strict'
const EventEmitter = require('events').EventEmitter
const { poolConnectChannel, poolReleaseChannel, poolRemoveChannel, shouldTrace } = require('./diagnostics')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Published pools fail to load 🐞 Bug ≡ Correctness

pg-pool/index.js now requires ./diagnostics, but the package's files list excludes
diagnostics.js. When pg-pool is installed from a published package, both its CommonJS entry and
ESM wrapper reach that missing module.
Agent Prompt
## Issue description
The published pg-pool package omits the new module required by its entry point, so imports fail.
## Fix Focus Areas
- packages/pg-pool/package.json[46-49]
- packages/pg-pool/index.js[3-3]
## Recommended Fix
Add `diagnostics.js` to the package's `files` list and verify it appears in a package archive.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread packages/pg/lib/client.js
this._pulseQueryQueue()
}

if (shouldTrace(queryChannel) && query.callback) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

2. Event-based queries escape tracing 🐞 Bug ◔ Observability

Client.query() starts a trace only when query.callback exists, leaving callback-free Query
instances outside the new channel. The supported event-based query API submits those instances and
reports completion through end or error events, so subscribers receive no lifecycle events for
them.
Agent Prompt
## Issue description
Event-based Query instances execute without a callback and therefore produce no query diagnostics.
## Fix Focus Areas
- packages/pg/lib/client.js[622-635]
- packages/pg/lib/client.js[703-738]
- packages/pg/lib/query.js[128-149]
## Recommended Fix
Add tracing for callback-free Query instances using their completion and error events, without changing their event-based API.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread packages/pg/lib/client.js
Comment on lines +722 to +724
const enrichedCb = (err, res) => {
if (res) context.result = { rowCount: res.rowCount, command: res.command }
return origCb(err, res)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

3. Multi-statement traces lose results 🐞 Bug ◔ Observability

enrichedCb reads rowCount and command from res as though it were always one result object.
For a successful multi-statement query, Query passes an array of results, so the published result
metadata has neither statement's command nor row count.
Agent Prompt
## Issue description
Multi-statement queries return an array, but tracing extracts fields as if the response were one result.
## Fix Focus Areas
- packages/pg/lib/client.js[721-724]
- packages/pg/lib/query.js[59-68]
## Recommended Fix
Handle array results explicitly and publish metadata for each statement while retaining the single-result shape for ordinary queries.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment thread packages/pg/lib/client.js
Comment on lines +721 to +724
const origCb = query.callback
const enrichedCb = (err, res) => {
if (res) context.result = { rowCount: res.rowCount, command: res.command }
return origCb(err, res)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remediation recommended

4. Query callbacks lose their receiver 🐞 Bug ≡ Correctness

enrichedCb invokes the saved callback as origCb(err, res), discarding the query instance
previously supplied as its receiver. When tracing is subscribed and a query callback uses this, it
no longer sees the Query instance on either success or error.
Agent Prompt
## Issue description
The tracing wrapper changes the receiver observed by existing query callbacks.
## Fix Focus Areas
- packages/pg/lib/client.js[721-735]
- packages/pg/lib/query.js[128-149]
## Recommended Fix
Use a non-arrow enrichment callback and invoke the saved callback with the receiver supplied to the traced callback, preserving its arguments and return value.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 6 potential issues.

Devin Review

Comment thread packages/pg-pool/index.js
@@ -1,5 +1,6 @@
'use strict'
const EventEmitter = require('events').EventEmitter
const { poolConnectChannel, poolReleaseChannel, poolRemoveChannel, shouldTrace } = require('./diagnostics')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Published pool package cannot load

Installed copies of pg-pool fail to load because ./diagnostics is absent from the published package. The package allowlist includes the entry point but excludes the new module.

Learn more

The pool entry point now requires a sibling module at load time. The files allowlist in package metadata excludes that module. An npm pack --dry-run --json listing confirms the tarball contains index.js but no diagnostics.js. Every installation from this tarball fails before creating a pool.

Example: A consumer installs the published pg-pool tarball and calls require('pg-pool'). Node resolves index.js but cannot resolve ./diagnostics, so it throws MODULE_NOT_FOUND.

Recommended fix: Add diagnostics.js to the files allowlist in packages/pg-pool/package.json, and verify it appears in npm pack --dry-run --json.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread packages/pg/lib/client.js
Comment on lines +726 to +735
queryChannel.traceCallback(
(tracedCb) => {
query.callback = tracedCb
enqueue()
},
0,
context,
null,
enrichedCb
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Timed-out queries leave tracing spans unfinished

When query_timeout fires, traceCallback never receives the error because the timer calls the saved queryCallback directly. The span emits start but never emits error or asyncEnd.

Learn more

The timeout handler in Client.query saves queryCallback before tracing is installed. On timeout it invokes that original callback directly, then replaces query.callback with a no-op. The tracing callback installed here never runs. A tracing subscriber sees an open query indefinitely despite the application receiving a timeout error.

Example: A SELECT pg_sleep(10) query with query_timeout: 10 emits pg:query:start. After 10 ms its promise rejects, but pg:query:error and pg:query:asyncEnd never fire.

Recommended fix: Route the timeout error through the traced callback exactly once, while preserving the existing suppression of any subsequent database completion. Add a timeout-specific tracing test.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread packages/pg/lib/client.js
this._pulseQueryQueue()
}

if (shouldTrace(queryChannel) && query.callback) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Event-driven queries disappear from tracing

When an event-driven Query has no callback, pg:query emits no events despite executing the query. The query.callback guard skips tracing, leaving these queries invisible to subscribers.

Learn more

A caller can pass a Query object to Client.query and consume row, end, and error events without setting Query.callback. Query.handleReadyForQuery emits end even without a callback, and Query.handleError emits error. This guard traces only callback-backed queries, so event-driven operations never appear on the new query channel.

Example: client.query(new Query('SELECT 1')).on('end', handler) completes normally, but a subscriber to pg:query sees no start or completion event.

Recommended fix: Instrument Query event completion/error as well as callback completion, or otherwise supply a completion hook for callback-free Submittables without changing their event-based API.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread packages/pg/lib/client.js
Comment on lines +722 to +724
const enrichedCb = (err, res) => {
if (res) context.result = { rowCount: res.rowCount, command: res.command }
return origCb(err, res)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Multi-statement traces lose result metadata

For multi-statement queries, enrichedCb reads rowCount and command from an array instead of its results. Subscribers receive neither command nor row count for those queries.

Learn more

Query._checkForMultirow converts multi-statement results into an array. Query.handleReadyForQuery passes that array to the callback. This enrichment reads properties directly from the array and records both as undefined, while single-statement queries receive valid metadata.

Example: client.query('SELECT 1; SELECT 2') returns two result objects, but pg:query:asyncEnd has result: { rowCount: undefined, command: undefined }.

Recommended fix: Detect an array of results and publish metadata for each statement, while retaining the current single-result shape for ordinary queries.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread packages/pg/lib/client.js
Comment on lines +703 to +709
const enqueue = () => {
if (this._queryQueue.length > 0) queryQueueLengthDeprecationNotice()
this._queryQueue.push(query)
this._pulseQueryQueue()
}

if (shouldTrace(queryChannel) && query.callback) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Measure the no-subscriber query path

Even without subscribers, Client.query creates an enqueue closure and checks the channel. Benchmark the hot path before relying on the no-overhead claim.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +6 to +15
// TracingChannel exists on Node 18+ but the aggregated hasSubscribers getter
// and stable unsubscribe behavior require Node 19.9+/20.5+. Skip tests on
// older versions where TracingChannel is missing or has internal bugs.
const hasStableTracingChannel =
typeof dc.tracingChannel === 'function' && typeof dc.tracingChannel('pg:test:probe').hasSubscribers === 'boolean'

const suite = new helper.Suite()
const test = suite.test.bind(suite)
// pass undefined as callback to skip when TracingChannel is unavailable/unstable
const testTracing = (name, cb) => test(name, hasStableTracingChannel ? cb : undefined)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Node 18 compatibility path lacks coverage

The tests skip versions without an aggregated hasSubscribers getter, while shouldTrace traces unconditionally there. Add coverage for that distinct execution path.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@MiichelleZhou
MiichelleZhou deleted the eval/3650/qodo/round-7 branch September 28, 2026 22:11

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b922f0d. Configure here.

Comment thread packages/pg-pool/index.js
@@ -1,5 +1,6 @@
'use strict'
const EventEmitter = require('events').EventEmitter
const { poolConnectChannel, poolReleaseChannel, poolRemoveChannel, shouldTrace } = require('./diagnostics')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Published package missing diagnostics module

High Severity

index.js now requires ./diagnostics, but the pg-pool files list still only ships index.js and esm. Installing the published package fails at load time with a missing-module error, which also breaks pg because it depends on pg-pool.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b922f0d. Configure here.

Comment thread packages/pg/lib/client.js
context,
null,
enrichedCb
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query timeout skips tracing completion

Medium Severity

When query_timeout fires, the timeout path invokes the pre-trace callback and then replaces query.callback with a noop. Tracing already published start around enqueue, so asyncEnd and error never run and APM spans stay open for timed-out queries.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b922f0d. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants