GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||
GeezerVison is showing github.com — Add `onConnect` callback which allows "setup" of a pooled client by brianc · Pull Request #3620 · brianc/node-postgres Conversation
|
Deploying node-postgres with
|
| Latest commit: |
dd906fe
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2715f9f7.node-postgres.pages.dev |
| Branch Preview URL: | https://bmc-pool-callbacks.node-postgres.pages.dev |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| maxLifetimeTimeout.unref() | ||
| client.once('end', () => clearTimeout(maxLifetimeTimeout)) | ||
| if (this.options.onConnect) { | ||
| let hookResult |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
How about a single promiseTry(this.options.onConnect).then(…, …) path? Where
const promiseTry = Promise.try ?? (f) => new Promise((resolve) => { resolve(f()) })
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I guess this gets a little more complicated if it has to support the custom Promise config option.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
(Note: I’m bringing this up ahead of publishing instead of making a follow-up PR because the behaviour is slightly different, so it would be a breaking change.)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
much appreciated! Though I'm not sure what you mean by a breaking change...what's a breaking change, exactly?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The promiseTry suggestion, compared to what’s currently in this PR. They’re slightly different from each other, so it couldn’t wait until afterwards, I mean.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
yah i get it, i just don't understand how they'd be different enough to introduce a breaking change later. I'll try your approach & see if the tests still pass. I kinda approached this from a TDD perspective - mostly want a "pricipal of least surprise" where if your onConnect throws for any reaons (sync or async) the connection is just aborted & the error is propagated out to the caller of pool.connect / pool.query. Usually my first approach is "if the tests pass, i'm happy, and can optimize or change the internals later if needed." Anyways...will try your approach out now locally & see how it does.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
@charmander updated to use Promise.try and still attempt to support BYOP. Though we're removing BYOP in 9.0. I'm going to work on the 9.0 roadmap today here by pulling in ideas and discussions from the discussion about it. I'm hoping to finalize it today, cut a branch tomorrow, and start working on it. I don't think its a TON of work & I plan on doing most or all of it...just wanted to share! thanks again for all you do! ❤️
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks good!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I forgot |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
yah i dunno what that verify thing is anymore, but imma deprecate it in a follow up PR once this ships as a kinda just better alternative I think. Will look into it more tomorrow. TY For the review! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
Future Support for Setup Queries When a New Pool Client Connects
There was an error while loading. Please reload this page.