Skip to content
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

[v3] Slowdown because of large source maps for queries that don't error #273

Closed
mohe2015 opened this issue Mar 11, 2022 · 4 comments
Closed

Comments

@mohe2015
Copy link

I assume because of

query.origin = options.debug ? new Error().stack : cachedError(xs)

stack traces are generated. It seems like the caching does not work as they seem to be re-generated for every request. nodejs/node#41541 also plays into this but still I don't understand why this is necessary. If you need a minimally reproducible example please tell me and I will try to provide one. The relevant thing is probably that cachedError should only calculate the stack trace the first time. What are some reasons this does not work? The queries are wrapped in a transaction. The following is the code that creates the pool.

export const sql = postgres(process.env["DATABASE_URL"], {
  host: process.env["DATABASE_HOST"],
});

image

@porsager
Copy link
Owner

Thanks a lot for this issue. I'll give it a closer look Sunday.

@porsager
Copy link
Owner

porsager commented Mar 13, 2022

Yeah, that looks like an oversight on my part for .unsafe()... Since the caching relies on the first argument from the tagged template function it's not possible to make origin work for unsafe.

I think it should be changed to get the stack only if the error is thrown either way. Don't know why I hadn't thought of that.

@porsager
Copy link
Owner

porsager commented Mar 13, 2022

Would you mind trying 0aacdb3 (current rewrite branch) out to see if there's an improvement?

I have a vague memory testing this at some point only to find it didn't have much of an effect, but let's see :) If it's still just as bad, I think adding origin to the stack should be removed from .unsafe().

@mohe2015
Copy link
Author

It looks fixed. If it will happen again I will reopen. Thanks for fixing this!

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

No branches or pull requests

2 participants