-
Notifications
You must be signed in to change notification settings - Fork 205
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
Use a singleton for the DB connection object #5257
Conversation
Preview URL 🚀 : https://blurts-server-pr-5257-mgjlpikfea-uk.a.run.app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think this is a better approach here. Could you please file a ticket to refactor the rest of the code to use this approach?
8cdd6d7
to
e7a2b23
Compare
The risky bit is that this already ensures all |
Preview URL 🚀 : https://blurts-server-pr-5257-mgjlpikfea-uk.a.run.app |
Cleanup completed - database 'blurts-server-pr-5257' destroyed, cloud run service 'blurts-server-pr-5257' destroyed |
Yes thinking of e.g. blurts-server/src/scripts/cronjobs/emailBreachAlerts.tsx Lines 427 to 429 in c2e3402
|
References:
Jira: MNTOR-3606
Figma:
Description
This is the riskier sibling to #5254, where I'm trying to figure out what could be causing the monthly-activity-free cronjob to be hanging.
In this PR, I call
destroy()
on the connection object when it's done - but more importantly, I have everydb/tables
module re-use the same connection object, to avoid having to do this:blurts-server/src/scripts/cronjobs/emailBreachAlerts.tsx
Lines 427 to 429 in 0da0296
I think this should be safe, and in practice, the connections should be pooled already, but there might always be unforeseen effects, so please take some time to think about potential problems and/or ways to catch any that might occur.