- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
No handlers for SASL errors #1927
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
Comments
This is still an issue as of pg 8.7.1. To reproduce, attempt to connect to a PG instance that uses scram and don't specify a password when connecting: const client = new Client();
try {
await client.connect();
} catch (err) {
// this is never reached
} You'll get an uncaught exception: |
I’m building a CLI app that uses When I leave all connection arguments empty as a user of the app, it crashes with this very confusing error. As a developer of the app, I don’t see any way to catch this error to provide any context to the user as to why it crashed and exit gracefully. If it’s possible to prioritise fixing this, I would appreciate it greatly. |
@rpominov Check if it’s missing before making a connection attempt. |
I think postgres allows to setup the server so that you can connect without a password. Also checking the password is not trivial, as it can come from at least 4 places that I'm aware of:
In general, there seem to be a lot of authentication methods that node-postgres supports that I don't fully understand. Ideally, I want to just pass the options to node-postgres and show any errors that it produces back to the user, while stating in the documentation that they can use whatever authentication method that the library supports. |
We're encountering this issue over at Sequelize after updating our CI to use postgres 14 (PR sequelize/sequelize#14737) We have a test that checks that an error is raised is the password is invalid (in this case null), but because the error is not sent to |
Leaving a note here as a reminder to take another look at the SASL error handling. At first glance I don't think the errors would bubble up as they're thrown synchronously in the helper functions and the caller does not catch or emit them up to the client.
node-postgres/lib/sasl.js
Lines 4 to 17 in 0acaf9d
node-postgres/lib/client.js
Lines 142 to 146 in 0acaf9d
The text was updated successfully, but these errors were encountered: