Refreshing the database connection #2862
Replies: 2 comments 2 replies
-
more specifically I want to have a wrapper around the db class that whenever a query fails due to closed connection (or if it's possible to know when the connection is broken), it retries to connect (don't mind the retry logic and when it should stop trying I can manage that) |
Beta Was this translation helpful? Give feedback.
-
Well, you'll never guess who wrote that snippet 😬 But I agree that opening an issue on the
It's probably easier to not do this around the whole database class, but rather over the underlying connection only. Then you don't have to open the whole database class again. You can take a look at the postgres implementation for this and possibly adapt it to handle connection errors. But it's probably very tricky to get right, I imagine handling transactions might be a challenge. |
Beta Was this translation helpful? Give feedback.
-
Sometimes the connection to my database is lots (for 3rd party reasons) and I want to close and reopen my connection.
I'm using provider and I'm not sure how to approach this... here's the current code:
when I do
db.close()
after loosing internet connection for example and regaining it, the function hangs and is awaited forever trying to close the db. No error is thrown either. Is there a way to know where the error happens? Cuz no message so can't know.Update for the hanging
db.close()
in postgres-3.0.7 package in connection.dart I found it's getting stuck here forever:
print s4 is never printed. If I remove this lock then it works normally. This is the other packages problem so don't mind it. I'll probably find something. Only interested in the listener now that lets me act upon loss of connection
Beta Was this translation helpful? Give feedback.
All reactions