Dexie.js icon indicating copy to clipboard operation
Dexie.js copied to clipboard

BUG: Weird misbehavior on Safari using middleware & blob

Open angelaki opened this issue 1 year ago • 12 comments

When using a middleware that modifies a record containing a blob the code crashes on latest Safari (17.4 [19618.1.15.11.12]) with an error:

UnknownError: Error preparing Blob/File data to be stored in object store UnknownError: Error preparing Blob/File data to be stored in object store

This only happens in some scenarios. E.g. it depends on the total number of records in the table and the blob type! Is this a known bug? Any idea for this?

Here you can see a minimal repro: Stackblitz

  1. Hit "Prepare"
  2. Wait a few seconds
  3. Hit Crash (maybe a few times)

Sometimes you have to restart the browser, wait a moment, hit Crash several times ... it's pretty random

angelaki avatar Mar 13 '24 15:03 angelaki

Sorry for bumping but this bug really is super important for me right now. Any chance to get a soon response?

angelaki avatar Mar 19 '24 10:03 angelaki

It seems this hasn't to do with middleware. I modified the repro to insert the flags in the put operations and could make it crash also then: https://stackblitz.com/edit/stackblitz-starters-huwmol?file=src%2Fmain.ts

I think we will be able to workaround this issue the same way we do for other uknownerror problems we workaround. We should probably be catching the UnknownError and retry the operation under the hood.

This will have to wait to after the Dexie Cloud launch on March 27 but I see it as an important as it is in line with how dexie generically works around issues like these.

dfahlander avatar Mar 19 '24 12:03 dfahlander

Oh, I didn't notice! Tought I correctly broke it down to the middle ware. This minimal repro was a two day bug hunt ... Don't you even ask ... But thank you so much for investigating! Looking forward for the next version!

angelaki avatar Mar 19 '24 14:03 angelaki

Guess that's not included in the latest 4.0.2, is it? Any estimations possible? But no hurries! :)

angelaki avatar Apr 10 '24 09:04 angelaki

No it's not. I've set May 15 as end date on this issue in the project and prio 1. But it's still a guess.

dfahlander avatar Apr 10 '24 10:04 dfahlander

Ah, just seen it! Thank you very much! :)

angelaki avatar Apr 10 '24 10:04 angelaki

Sorry for bumping, but guess fix didn't make it to 4.0.8, yet?

angelaki avatar Jul 11 '24 07:07 angelaki

Correct, it's not there yet.

dfahlander avatar Jul 11 '24 08:07 dfahlander

Sorry to nag again but - news on this? Asking because I just hit another issue: Right now getting pretty ofter a dataloss error (https://forums.developer.apple.com/forums/thread/750122). Happens with new IPads it seams ...

Anything I can do right now? End the connection, wait a second and try again? Closing / opening the browser solves the issue right now.

angelaki avatar Nov 21 '24 12:11 angelaki

Thanks for reminder

dfahlander avatar Nov 22 '24 13:11 dfahlander

Small reminder, again? Sorry for bumping 😶‍🌫️

angelaki avatar Jun 25 '25 10:06 angelaki

Just noting that I'm seeing the same in both desktop/mobile safari (latest versions), especially in private browsing.

In my case, nothing to do with middleware, but just object creates/updates when it contains a blob.

Looks like my experience is very similar to #1227

My solution at this time is to convert the blob/file to something resembling what emscripten does, where I store the name/mime type/binary data as a Uint8Array.

thenick775 avatar Jul 13 '25 03:07 thenick775