Replies: 3 comments 4 replies
-
From a quick look, the code looks correct to me (well, except that you'll probably want to await Since an |
Beta Was this translation helpful? Give feedback.
-
An update on this issue, I still am At this point the only problem seems to be the I tried doing what you suggested and buffering the entire download into a variable and doing a single call to
Update: The below turned out to be a bug on my end -- specifically what was happening is what you first suggested which I was opening the database earlier than I realized. My DB update logic actually checks the timestamp in the local database to decide if an update is necessary, thus I was opening the database -- downloading a new database -- and not closing the original connection which was causing problems. The fix was, upon updating the database, rebuild the connection. Since I was using a singleton via
@simolus3 any further thoughts or information I can help provide? |
Beta Was this translation helpful? Give feedback.
-
More updates! I don't know why it's happening but I've gotten a step closer to identifying why, when the download seems to work, I end up with a database that has no tables in it. Here's what I'm observing:
So it seems like there is something happening here where the database I downloaded is being overwritten with an empty database. I've noted the following: If I download the database successfully (Step 1), skip Step 3 (try to use it), and instead hot-reload the Flutter application... on the 2nd run through it doesn't try to download the database again (as expected), and it doesn't klobber the database when I go to use it at Step 4. This implies to me there is something not happening once I write the database to the VFS causing the klobbering issue -- something that happens automatically when I hot reload (e.g. maybe a resource isn't being closed and reopened that needs it?) Does that help at all? |
Beta Was this translation helpful? Give feedback.
-
I've got a problem that's hard to nail down...
The way I'm using drift is to build an SQLite database on a server, and then have the flutter app (web, specifically) download that database occasionally using
dio
, and write it to the IndexedDb VFS... from there drift can perform queries on it. The database is about 5.5MB in size.Occasionally I am running into a problem where the new database doesn't download properly. When I look at the
filesize
attribute in thefiles
for IndexedDb, sometimes for example it's only65535
. Sometimes, it's showing the proper filesize but then SQLite says the tables don't exist... sometimes the VFS freaks out and starts constantly throwing exceptions about Array access being out of bounds (with an constantly decreasing negative length value).Then, sometimes, it just works like it is intended to.
Needless to say I'm at a bit of a lost.
@simolus3 I'm sure I'm pushing the limits of the current capabilities here, so maybe you have some insight? Below is my code to write to the IndexedDb VFS.. is there anything here you are seeing that would cause this?
Beta Was this translation helpful? Give feedback.
All reactions