Skip to content

sql: fix the build after #32089 × #37275 (LISTEN/NOTIFY error path) - #38628

Merged
dylan-conway merged 2 commits into
mainfrom
claude/fix-sql-listen-build
Aug 14, 2026
Merged

sql: fix the build after #32089 × #37275 (LISTEN/NOTIFY error path)#38628
dylan-conway merged 2 commits into
mainfrom
claude/fix-sql-listen-build

Conversation

@dylan-conway

Copy link
Copy Markdown
Member

What does this PR do?

main does not compile: #32089 (sql.listen/notify) calls JSGlobalObject::report_active_exception_as_unhandled, which #37275 removed (bun_sql_jsc: "no method named report_active_exception_as_unhandled", ×2 in PostgresSQLConnection.rs).

A NOTIFY channel/payload string the VM could not make (OOM, a worker's termination) is now handled the way every other JS conversion failure inside PostgresSQLConnection::on() is: on_notification returns AnyPostgresError::JSError, and the connection's error path takes the pending exception and fails the connection with it — which is also #37275's rule that an Err always leaves its exception pending for exactly one taker.

How did you verify your code works?

cargo check -p bun_sql_jsc and cargo check -p bun_bin (full crate graph) pass. The LISTEN/NOTIFY tests need a Postgres server (CI's docker lane).

…he connection's error path

#32089 landed calling JSGlobalObject::report_active_exception_as_unhandled,
which #37275 removed, so main does not compile. A NOTIFY channel/payload
string the VM could not make (OOM, a worker's termination) is now this
connection's failure like every other conversion in on(): on_notification
returns AnyPostgresError::JSError, which takes the pending exception.

No-Verification-Needed: build fix; cargo check of the full crate graph passes, the sql suite needs a Postgres server
@coderabbitai

coderabbitai Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 36 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 37653efe-9266-45d3-84bb-157817ba6e33

📥 Commits

Reviewing files that changed from the base of the PR and between d3161f0 and ec710af.

📒 Files selected for processing (1)
  • src/sql_jsc/postgres/PostgresSQLConnection.rs

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: ec45d9cc-520d-4062-9424-22350d280d73

📥 Commits

Reviewing files that changed from the base of the PR and between 2f5c180 and d3161f0.

📒 Files selected for processing (1)
  • src/sql_jsc/postgres/PostgresSQLConnection.rs

Walkthrough

Notification handling now propagates JavaScript string-conversion failures as AnyPostgresError::JSError. Channel conversion and notification dispatch return Result values, and the PostgreSQL message handler propagates those results.

Changes

PostgreSQL notification error propagation

Layer / File(s) Summary
Propagate notification conversion errors
src/sql_jsc/postgres/PostgresSQLConnection.rs
channel_name_js returns conversion errors as JSError. on_notification and NotificationResponse processing propagate those errors while preserving existing early returns.

Suggested reviewers: jarred-sumner, robobun

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the SQL LISTEN/NOTIFY error-path build fix caused by related changes.
Description check ✅ Passed The description includes both required sections and explains the change, error-handling behavior, and verification steps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — straightforward build fix routing NOTIFY string-creation failures through the same AnyPostgresError path every other on() arm uses. The inline nit about js_error_to_postgres is a convention point only; create_utf8_for_js is zero_is_throw so both spellings are behaviorally identical today.

Extended reasoning...

Overview

#32089 (LISTEN/NOTIFY) landed calling JSGlobalObject::report_active_exception_as_unhandled, which #37275 had removed, so main stopped compiling. This PR changes on_notification and its helper channel_name_js to return Result<_, AnyPostgresError> instead of swallowing/reporting the exception locally, and adds ? at the single call site inside PostgresSQLConnection::on(). Net ~30 lines in one file.

Security risks

None. No new inputs, no parsing changes, no trust-boundary changes — this only reroutes an existing OOM/termination error path from a removed reporter to the connection's existing failure path.

Level of scrutiny

Low. This is a mechanical build fix that makes the NOTIFY arm match every sibling arm in the same match (decode_internal(...)?, ok_or(...)?, etc. all already propagate AnyPostgresError out of on()). Both changed functions have exactly one caller each, both updated. The early-return Ok(()) cases (no JS wrapper / no callback registered) preserve the previous no-op semantics.

Other factors

  • Verified downstream: AnyPostgresError::JSError routes through error_jsc.rsglobal.take_exception(JsError::Thrown), which is exactly what #37275's contract expects (the pending exception is left for one taker).
  • The one inline nit (use crate::jsc::js_error_to_postgres instead of |_| AnyPostgresError::JSError) is a valid convention point but not a behavior difference here — BunString__createUTF8ForJS is [[ZIG_EXPORT(zero_is_throw)]] and only ever yields JsError::Thrown, so the OutOfMemory branch the helper preserves is unreachable for this call. Worth applying, not worth blocking a build fix on.

Comment thread src/sql_jsc/postgres/PostgresSQLConnection.rs Outdated
…OM mapping)

No-Verification-Needed: same behaviour via the crate's helper; cargo check passes
@dylan-conway
dylan-conway merged commit b9ef885 into main Aug 14, 2026
8 of 9 checks passed
@dylan-conway
dylan-conway deleted the claude/fix-sql-listen-build branch August 14, 2026 18:36

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM — the js_error_to_postgres nit from the prior review is addressed in ec710af; both conversion sites now use the crate helper.

What was reviewed:

  • on_notification/channel_name_js now return Result<_, AnyPostgresError> and the new ? in on() matches every sibling arm's error propagation.
  • Confirmed js_error_to_postgres maps JsError::{Thrown,OutOfMemory}AnyPostgresError::{JSError,OutOfMemory}, so the pending-exception contract from #37275 holds.
  • Early-return guards (js_value unset, no onnotification callback) still return Ok(()) — no behavior change on the happy path.
Extended reasoning...

Overview

Build fix for main: #32089 (LISTEN/NOTIFY) landed calling JSGlobalObject::report_active_exception_as_unhandled, which #37275 removed. The two call sites in PostgresSQLConnection.rs are rewritten to return Result<_, AnyPostgresError> and propagate via ? through on(), using the crate's documented .map_err(crate::jsc::js_error_to_postgres)? convention. Net diff is ~20 lines in one file.

Security risks

None. No new inputs parsed, no allocation logic changed, no trust boundaries crossed. The only reachable error case is OOM/STRING_TOO_LONG when converting a Postgres NOTIFY channel/payload to a JS string, which now fails the connection through the same path every other on() arm uses instead of being reported as an unhandled exception.

Level of scrutiny

Low. This is a mechanical build fix aligning two brand-new call sites with the crate's existing error-propagation pattern (PostgresRequest.rs, Signature.rs, DataCell.rs all use the same helper). The on() dispatch already returns Result<(), AnyPostgresError> and every sibling arm uses ?, so the new ? on on_notification is structurally identical.

Other factors

My previous review flagged that the first revision hand-rolled |_| AnyPostgresError::JSError instead of using js_error_to_postgres; ec710af addressed it and the thread is resolved. cargo check passes per the PR description; the LISTEN/NOTIFY tests run in CI's docker lane. No outstanding review comments.

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.

1 participant