porsager / postgres

Postgres.js - The Fastest full featured PostgreSQL client for Node.js, Deno, Bun and CloudFlare
The Unlicense
7.54k stars 273 forks source link

Fix ambiguous error on startup #944

Open alexgleason opened 2 months ago

alexgleason commented 2 months ago

Fixes https://github.com/porsager/postgres/issues/923

Before & after:

Screenshot from 2024-09-15 18-58-17

martinwepner-otto commented 2 months ago

Would be nice if this could be merged and released soon. In my team multiple developers ran into this when trying to connect with wrong credentials and the "cannot read property "replace" of undefined" was not very helpful.

fin-dogedev commented 2 months ago

This runtime type error causes the application to terminate if the connection to the database fails unexpectedly. As a result, the reconnection mechanism cannot take effect.

coder-se commented 1 month ago

Is there anything blocking this from being merged? Would be really good to get this into a release. The issue has been around since beginning of this year causing applications to terminate like @fin-dogedev says.

Any thoughts @patrickReiis , @porsager ?

chanon commented 1 month ago

Please merge this. Is this project still being maintained?

porsager commented 1 month ago

there are no tests so that means I need to spend time to make them and verify the fix myself - I'm not on a big surplus of time at the moment, and don't use deno myself, so can't easily verify the pr myself.

porsager commented 1 month ago

also changes should only be made to the src, the rest of the files are auto generated

chanon commented 1 month ago

FYI it also happens in the Node.js version I am using v20.13.1

Also it is an uncaught exception that kills the process, so not sure how to write a test for it. I guess spawn/exec and read the error output? The fix is very simple though so not sure a test is required.

In addition to the code changed, also see the root of the issue noted here: https://github.com/porsager/postgres/issues/923#issuecomment-2266235503

wataruoguchi commented 2 weeks ago

During development, I had the same issue as https://github.com/porsager/postgres/issues/778. I can reproduce the issue with my repository.

I confirmed the change in the src/connection.js (Node.js) in this PR has solved the issue.

I support this PR because the queryError function expects query to be an object. If the query is NOT an object, the queryError function fails anyway. I hope this PR gets merged.

Side note: During development, we need to use NodeJS's module by adding an alias.

alexgleason commented 1 week ago

also changes should only be made to the src, the rest of the files are auto generated

I updated to only include changes to src.

alexgleason commented 1 week ago

I do not know how to reproduce an SSL connection error in a test. This issue is apparently also occurring in Node https://github.com/porsager/postgres/issues/923#issuecomment-2462024110