-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pool.query() does not throw error with full stack trace #1762
Comments
Hi, could you post the incomplete stack trace and the code that generates the error? Without knowing more about your case however, I’m guessing that it might have something to do with this infamous bug in node/V8, which can’t be fixed in this library |
Hi Joe, Yes, I got it, my case is similar like that. Now I know that we can't fix it in this library. What can we do in this case?, or just wait for node.js team?. |
You can try some of the workarounds suggested in that issue:
const bluebird = require('bluebird');
const { Client, Pool } = require('pg');
const pool = new Pool({
Promise: bluebird
});
// for this one, only available in pg@7.6.0 and up:
const client = new Client({
Promise: bluebird
}); |
Thank Joel, I will try all of it. I also let this issue is open to show that it should be solve, some how. |
@joelmukuthu’s covered it all; stack traces get lost by default in JavaScript when asynchronous tasks aren’t direct calls. |
Now that zero-cost async stack traces are part of Node (v12) by default, it would be great if this could be reconsidered. I'm not sure what the reason is that this is still broken in node-pg, maybe because node-pg doesn't use native promises or native async functions? |
the reason is this project has been maintained almost entirely by myself and 1 other person for the past decade and we're buried under bug reports, feature requests, internal priorities. Also, the world has fallen into a global pandemic causing me significant anxiety attacks. Also, we still support versions of node back to 6.0. |
with the 9.0 internals re-write i'll be starting as soon as I can catch my emotional breath I'm going to investigate switching fully async/await (as much as possible) internally. We'll see how the perf of that is, but if that works you might just get this (and every other feature ever since it's open source) for free! |
No problem, sorry that I appeared to be demanding stuff for free. Mainly I think this issue could be reopened, since the original reason where this was not possible at all due to node restrictions is gone. |
ah gotcha! Yeah no worries - I get a _lot_ of email and you know tone of
voice and stuff doesn't carry well over text. :p I'll definitely keep
this in mind when I'm working on performance over the next few months. I
also think the current stack traces are gross and hard to deal with so I'm
all for fixing them! First up I want to get perf up a bit - some benchmarks
locally w/ some experiments I've done are showing upwards of 40-50% speed
increase in some cases.
…On Mon, Mar 30, 2020 at 10:37 AM phiresky ***@***.***> wrote:
No problem, sorry that I appeared to be demanding stuff for free. Mainly I
think this issue could be reopened, since the original reason where this
was not possible at all due to node restrictions is gone.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#1762 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAMHINOVYGALRGTSRRGHWLRKC4DRANCNFSM4GBW5KYA>
.
|
Not sure if I'm doing something wrong, but nothing in the above conversation or similar ones elsewhere worked. This is what I did, works and doesn't require more dependencies. Dunno if it'll work on older Node versions.
|
A big thank you. I don't know how popular FOSS maintainers do it all 👍 . I have the same problem. I am scared to use different types of promises and watnot. I am just going to try console logging before any DB operation, then I can see roughly when the EX happened. Obviously my use case is low volume! |
Props, though given that Node 6 was EOL'd April 2019, that's just crazy. At the time of this writing (May 2021), the oldest maintained LTS version is Node.js 12. |
I've made a PR to fix this: #2983 |
* fix stack traces of query() to include the async context (#1762) * rename tests so they are actually run * conditionally only run async stack trace tests on node 16+ * add stack trace to pg-native --------- Co-authored-by: Charmander <~@charmander.me>
brianc#2983) * fix stack traces of query() to include the async context (brianc#1762) * rename tests so they are actually run * conditionally only run async stack trace tests on node 16+ * add stack trace to pg-native --------- Co-authored-by: Charmander <~@charmander.me>
Issue of Pool.query().
Errors which are throw form Pool.query() does not contains full error stack trace. Please throw standard error with full stack trace.
The text was updated successfully, but these errors were encountered: