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

pg must be listed as dependency #99

Closed
IlyaSemenov opened this issue May 26, 2023 · 4 comments
Closed

pg must be listed as dependency #99

IlyaSemenov opened this issue May 26, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@IlyaSemenov
Copy link
Contributor

Problem

pg is not listed as a dependency of pqb, but internally pqb depends on it:

if (err instanceof pg.DatabaseError) {

DatabaseError was only exported in pg@8.10 so that should be the minimum allowed dependency version.

With older pg (as I happened to have, unfortunately) this leads to cryptic messages instead of database errors:

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
TypeError: Right-hand side of 'instanceof' is not an object
    at then (file:///.../node_modules/.pnpm/pqb@0.11.29/node_modules/pqb/src/queryMethods/then.ts:161:11)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Expected

pg is listed either as a peer dependency or a direct dependency of pqb, with a proper semver. I am not sure what's best so didn't create a PR.

@romeerez
Copy link
Owner

It's because I thought to support other postgres libraries in the future, but as it is only pg for now, it makes sense to add it as a direct dependency.

@romeerez
Copy link
Owner

The version that you've pointed out is 8.6, it was around 2 years ago so it should be fine for users.

But if you have an older version, how specifying the dependency would help, won't they conflict?

@IlyaSemenov
Copy link
Contributor Author

My bad, it's 8.6 indeed. I had a project with ^8.4.2 which was updated from 7.x in Oct 2020. I believe the versions wouldn't conflict due to how pnpm manages deps. Then they would have been deduped to the more recent version on the next pnpm dedupe.

@romeerez romeerez added the bug Something isn't working label May 27, 2023
@romeerez
Copy link
Owner

Published a change, now pqb has pg ^8.6.0 as a regular dependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants