Skip to content

Conversation

@lundibundi
Copy link
Member

  • Check DB connection status during startup
    otherwise we will get random unhandledRejection or 500 errors during API calls with errors like Password authentication failed for user with a long PG stacktrace

  • Pass 403 error code in signin

@lundibundi lundibundi requested a review from tshemsedinov April 3, 2022 02:57
@lundibundi lundibundi changed the title Fix siginin error code and db startup Check db startup and pass siginin error code Apr 3, 2022
db.pg = new metarhia.metasql.Database(options);

// Check that we connected successfully.
await db.pg.query('SELECT now()').catch((err) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we somehow detect connection status without a query?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To example, we can catch connection errors by manually creating connection using connect method from Pool:

await db.pg.pool.connect().catch((err) => {
....
});

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

Successfully merging this pull request may close these issues.

4 participants