iansinnott / prompta

ChatGPT UI that is keyboard-centric, mobile friendly, and searchable.
https://chat.prompta.dev
MIT License
154 stars 13 forks source link

Error initialising the database #5

Closed adamshand closed 9 months ago

adamshand commented 1 year ago

Hi,

I've been using the Prompta macOS application for a few days and really liking it, thanks!

Yesterday I pasted in a good chunk of JS error message trying to solve a problem and Prompta crashed. Since then, opening Prompta app has resulted in the below error message:

There was an error initializing the database. Please try again. If the problem persists, please report in on GitHub.sqlite3_open_v2.

image

Deleting ~/Library/WebKit/com.prompta.dev got rid of the error message, but Prompta still hangs forever on opening.

Deleting ~/Library/Caches/com.prompta.dev and I had to enter my API key again but everything is working.

iansinnott commented 1 year ago

Hey @adamshand , I'm seeing the same error although only in the PWA-installed version. I'm guessing you're getting this directly in the browser?

iansinnott commented 1 year ago

eh, sorry, i see you're using the installed macos version. latest version?

adamshand commented 1 year ago

Yes, I believe it's the latest version: Version 1.1.0 (20230717.161342)

adamshand commented 1 year ago

Just had it happen again when pasting JS code. If it happens again., I'll try and grab the content that seemed to cause it.

adamshand commented 1 year ago

Just got it again on the web interface at chat.prompta.dev (5:37pm NZT if you want to look at logs). Not JS code this time, just text.

image

iansinnott commented 1 year ago

What browser? I'm wondering if this is safari related, since the desktop build is equivalent

On Thu, Jul 27, 2023 at 1:37 PM, Adam Shand @.***> wrote:

Just got it again on the web interface at chat.prompta.dev (5:37pm NZT if you want to look at logs). Not JS code this time, just text.

— Reply to this email directly, view it on GitHub https://github.com/iansinnott/prompta/issues/5#issuecomment-1652943098, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAYCHMJWZNFZ4O4N5HU53VLXSH5CRANCNFSM6AAAAAA2XY7D6Q . You are receiving this because you commented.Message ID: @.***>

iansinnott commented 1 year ago

ah i see. responded from email which didn't have the image

iansinnott commented 1 year ago

I'm still not able to repro this. Tried in incognito Brave and the app seems to be working. There's definitely an issue, as i've seen it before too, but i don't currently have a way to reproduce the issue.

any thoughts? it seems like you're running into this fairly often?

iansinnott commented 1 year ago

I upgraded the database dependencies. This is where the wasm version of sqlite we use comes from.

Not that this will resolve the problem, but you could try the latest version and see if it's any different: https://github.com/iansinnott/prompta/releases/tag/v1.1.1

adamshand commented 1 year ago

Will upgrade and see how it goes, thanks!

No idea on reproducibility, seems pretty random, but often as chat logs get longer. Could it have something to do with tokens running out?

If I spot a pattern or can reliably reproduce, will let you know!

jdahlborg commented 1 year ago

Hello,

I encountered the following error just before the above mentioned problem while using the application:

sqlite-api.js:866 Uncaught (in promise) Error: database disk image is malformed at check (sqlite-api.js:866:11) at Object.step (sqlite-api.js:699:14) at async _TX.statements (TX.ts:152:17) check @ sqlite-api.js:866 (anonymous) @ sqlite-api.js:699 await in (anonymous) (async) submit_handler_1 @ +page.svelte:332

This issue has happened multiple times but unfortunately I'm unable to reproduce it. I'll also try to spot a pattern! I'm using chrome directly. Not PWA.

iansinnott commented 10 months ago

In a separate project I ran into a similar issue, which lead me to this: https://github.com/vlcn-io/js/issues/31

Prompta uses wa-sqlite with fts5 or search and persistence.

rhashimoto commented 10 months ago

@iansinnott I think there are two different problems in this thread. The one with the stack trace and "Error: database disk image is malformed" could indeed be https://github.com/vlcn-io/js/issues/31 for which the underlying problems in wa-sqlite and SQLite were recently fixed.

The one that just says "sqlite3_open_v2" doesn't match up with the above bug. There is no known wa-sqlite problem that fails within sqlite3_open_v2() like that. When this occurs, it would be helpful to check the browser Dev Tools JavaScript console for error messages.

iansinnott commented 10 months ago

Thanks for chiming in @rhashimoto. These may indeed be separate bugs, but when i've seen this pop up in the past they seem correlated. It usually goes like:

  1. Disk image malformed error
  2. (I restart the app)
  3. open_v2 error, assumedly due to malformed database

The app code has not done a good job of surfacing full stack traces for users to post though, so I'm speculating. Looking forward to your recent fix getting merged into vlcn

iansinnott commented 10 months ago

Anecdotally, I replaced the use of FTS5 with LIKE '%query%' in another app where I'm using vlcn, and so far have had zero issues. When using FTS5 the database would become malformed usually within hours of resetting it.