Skip to content
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

Console cannot write to IDB in Safari #46

Closed
olizilla opened this issue Nov 15, 2023 · 3 comments
Closed

Console cannot write to IDB in Safari #46

olizilla opened this issue Nov 15, 2023 · 3 comments
Assignees

Comments

@olizilla
Copy link
Contributor

Screenshot 2023-11-15 at 10 04 52

@gobengo
Copy link
Contributor

gobengo commented Nov 15, 2023

I was able to recreate this in my safari on desktop. For me, it happens after typing email and clicking 'Authorize' but before clicking the link in the email that got sent.

@travis travis self-assigned this Dec 4, 2023
@travis
Copy link
Member

travis commented Dec 5, 2023

Ok I dug into this - it seems to be an unreported bug with saving Uint8Arrays in IndexedDB. I spent hours trying to figure out the apparent error (Safari says it can't find a value for the key attribute in the data we're saving, when it's very clearly there) and finally started digging in this direction when I noticed the error doesn't happen if we don't try to save delegations. Converting the Uint8Arrays in the delegations to ArrayBuffers makes the issue go away.

The internet suggests that WebKit's handling of Uint8Arrays has been problematic - there's one bug I suspect may be related and generally Googling "indexeddb Uint8Array safari" paints a picture of a long history of poor support:

https://bugs.webkit.org/show_bug.cgi?id=197050

This claims that "Storing ArrayBuffers in IndexedDB is very well supported":

https://web.dev/articles/indexeddb-best-practices

I'm inclined to move to storing ArrayBuffers in all cases and to add a bit of logic to convert existing Uint8Arrays to ArrayBuffers when we see them - anyone have any thoughts on that plan?

travis added a commit to storacha/w3up that referenced this issue Dec 6, 2023
we noticed that Safari users couldn't log in:

storacha/console#46

I traced this down to a seemingly unreported WebKit bug where IndexedDB throws an error when saving Uint8Arrays in an object that uses inline-keys. I don't know these two things don't seem related, but
there does seem to be some similar precedent:

dexie/Dexie.js#656 (comment)

This change tweaks `AgentData`'s export format to use `ArrayBuffer`s rather than Uint8Arrays, which should solve the issue. I was able to handle coercing back into Uint8Arrays pretty elegantly, and introduced a new
`AgentDataImport` type to keep things typesafe.
travis pushed a commit to storacha/w3up that referenced this issue Dec 7, 2023
we noticed that Safari users couldn't log in:

storacha/console#46

I tracked this down to a seemingly unreported WebKit bug where IndexedDB
throws an error when saving `Uint8Array`s in an object that uses
inline-keys. I know these two things don't seem related, but there does
seem to be some similar precedent:

dexie/Dexie.js#656 (comment)

This change tweaks `AgentData`'s export format to use `ArrayBuffer`s
rather than `Uint8Array`s, which should solve the issue. I was able to
handle coercing back into Uint8Arrays pretty elegantly, and introduced a
new `AgentDataImport` type to keep things typesafe.
@travis
Copy link
Member

travis commented Dec 12, 2023

This is fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants