fix: support callback as second argument to CloudflareSocket.write - #3747
Merged
charmander merged 3 commits intoAug 14, 2026
Merged
Conversation
Emit the close event when the explicit close operation resolves and support the write(data, callback) overload used by Connection.end(). Fixes brianc#3152
charmander
requested changes
Aug 13, 2026
charmander
left a comment
Collaborator
There was a problem hiding this comment.
Doesn’t look right. Maybe start with a PR for just the write overload and a corresponding test that exercises it, ideally typed correctly with an overload instead of accepting (data, callback, callback).
Contributor
Author
|
Thanks — I narrowed this to the The updated method now has explicit overloads for |
charmander
requested changes
Aug 14, 2026
## Context - Principle: Callback tests must observe callback completion directly across the supported Node matrix - Why: The write overload regression should fail on a missing or duplicate callback without relying on event-loop timing ## Key Deltas - pg-cloudflare callback test: waited one event-loop tick and counted callbacks afterward -> awaits the callback and rejects a duplicate invocation inside it; why: the assertion now follows the callback contract while remaining compatible with Node 16. Key refs: packages/pg-esm-test/pg-cloudflare.test.js:21 ## Verification - Result: passed
charmander
approved these changes
Aug 14, 2026
CloudflareSocket.write
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.
Connection.end()callswrite(data, callback).CloudflareSocket.writepreviously treated the callback as an encoding, so it never ran.This adds explicit overloads for
write(data, callback)andwrite(data, encoding, callback). The runtime dispatch stays in the existingwritemethod; close and event behavior are unchanged.Validation:
pg-cloudflareruntime test: 3 passed;yarn build,yarn lint, Prettier, andgit diff --check: passed;write(data, callback, callback)fails with TS2345.The full PostgreSQL/libpq integration suite and a real Cloudflare Worker E2E were not run locally.
Prepared with Codex assistance.