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

Check db startup and pass siginin error code #185

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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 changed the title Fix siginin error code and db startup Check db startup and pass siginin error code Apr 3, 2022
@@ -4,4 +4,12 @@ async () => {
}
const options = { ...config.database, console };
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.

3 participants