Skip to content

fix(pg-cloudflare): prevent Client.end() from hanging - #3752

Merged
brianc merged 4 commits into
brianc:masterfrom
pratik-desgn:fix-cloudflare-socket-end-after-close
Sep 11, 2026
Merged

fix(pg-cloudflare): prevent Client.end() from hanging#3752
brianc merged 4 commits into
brianc:masterfrom
pratik-desgn:fix-cloudflare-socket-end-after-close

Conversation

@pratik-desgn

@pratik-desgn pratik-desgn commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #3152

Summary

  • complete Cloudflare shutdown when Socket.close() resolves but Socket.closed never settles
  • emit close once, with an identity guard preventing a duplicate event from the normal closed handler
  • add a regression test for a socket that never settles its closed promise

The callback overload used by Connection.end() is already present in the current base branch via #3747.

Validation

  • yarn lint
  • yarn workspace pg-cloudflare build
  • yarn workspace pg-esm-test test --test-name-pattern=pg-cloudflare (12 passed)
  • GitHub CI: lint and all 11 Node/PostgreSQL matrix jobs passed

The PR is limited to pg-cloudflare shutdown behavior and its focused ESM test.

@brianc

brianc commented Sep 11, 2026

Copy link
Copy Markdown
Owner

ya this looks p self-contained. the promise-y conditional code is hard to read but it definitely ends up that way sometimes w/ networking code in node unfortunately.

@brianc
brianc merged commit 5971813 into brianc:master Sep 11, 2026
12 checks passed
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.

Cloudflare Client.end() hangs if socket did not successfully connect

2 participants