feat!: remove support for a custom Promise implementation - #3733
Open
pri12ya871 wants to merge 1 commit into
Open
feat!: remove support for a custom Promise implementation#3733pri12ya871 wants to merge 1 commit into
pri12ya871 wants to merge 1 commit into
Conversation
Passing `Promise` to a Client, Pool or Cursor has been deprecated since the notice added for pg@9.0; this removes it. All four packages now use the global Promise. - pg/lib/client.js: drop `byoPromiseDeprecationNotice` and the `_Promise` field - pg/lib/native/client.js, pg-cursor/index.js: drop the same field - pg-pool/index.js: drop `this.Promise`, and with it the first parameter of the private `promisify()` helper, which existed only to carry it `Pool#_promiseTry` keeps its `Promise.try` fast path. That method exists on Node 23 and later but not on 16 through 22, which CI still covers, so the fallback stays. The integration test that asserted a supplied promise type was honoured now asserts the opposite, using a local Promise subclass so it no longer needs bluebird. bluebird is left in devDependencies for now because removing it would desync yarn.lock, and CI installs with --frozen-lockfile. Closes brianc#3631
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.
Closes #3631.
Removes the
Promiseconstructor option. All four packages now use the globalPromise.pg/lib/client.jsbyoPromiseDeprecationNotice, its trigger and the_Promisefield; 5 call sitespg/lib/native/client.jspg-cursor/index.jspg-pool/index.jsthis.Promise; 6 call sites, plus the first parameter of the privatepromisify()helper, which existed only to carry itOpen question — scope
I asked this on the issue and went ahead with the full removal so there's something concrete to look at, but I'm happy to cut it down.
pg-poolandpg-cursorare versioned separately frompg, so dropping theirPromiseoption is a breaking change for those packages in their own right, not only forpg@9.0. If you'd rather they went out with a coordinated major of their own, say so and I'll drop those two files — it's a clean partial revert and thepghalf stands on its own.Notes
test/integration/client/query-as-promise-tests.jsdidnew pg.Client({ Promise: bluebird })and asserted the returned promise was a bluebird. I inverted it to assert a supplied type is now ignored, using a localclass NotAPromise extends Promiseso the test no longer needs bluebird at all.Pool#_promiseTrykeeps itsPromise.tryfast path. That method exists on Node 23+ but not on 16–22, which CI still covers, so the fallback has to stay. Now that the constructor is always the global one this could arguably be simplified when the minimum Node version rises.bluebirdis left indevDependenciesforpgandpg-pool, where it's now unused. Removing it desyncsyarn.lockand CI installs with--frozen-lockfile, so it seemed better as a follow-up than bundled into this. Happy to include it if you'd prefer, with the lockfile regenerated.docs/.Testing
make test-unitpasses locally. I can't runtest-integrationortest-nativehere — Windows, no Postgres, andlibpqwon't build — so I leaned on CI for those. I did exercise the pg-pool paths directly, sincepool.end()needs no database:end()returns a native promise, a secondend()rejects through thePromise.rejectpath,_promiseTryresolves, and a suppliedPromiseis ignored.