WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
292721
TypedArray in IndexedDb key is mangled
https://bugs.webkit.org/show_bug.cgi?id=292721
Summary
TypedArray in IndexedDb key is mangled
markduckworth
Reported
2025-05-08 07:35:28 PDT
Created
attachment 475167
[details]
Full reproduction The result of this bug is that keys are incorrectly computed in WebKit and Safari. Reads based on key or range are not accurate. Reproducible with the following setup: Create an object store with key path consisting of two or more fields. ``` const openDBRequest = indexedDB.open(dbName, version); let db; openDBRequest.onupgradeneeded = event => { db = event.target.result; if (!db.objectStoreNames.contains(storeName)) { const objectStore = db.createObjectStore(storeName, { keyPath: ['bar', 'baz'] }); } }; ``` Add data, where any field but the last field in the key is a typed array value. ``` const transaction = db.transaction([storeName], 'readwrite'); const objectStore = transaction.objectStore(storeName); const put = objectStore.put({ bar: new Uint8Array([1,2,3]), baz: 1 }); ``` Read the key for the value you just wrote and see that the key value representing `bar` is not an accurate representation of the value on the object. ``` objectStore.getAllKeys().onsuccess = evt => { const idbValidKeys = evt.target.result; idbValidKeys.forEach(idbValidKey => { // UNEXPECTED BEHAVIOR: // Should equal new Uint8Array([1, 2, 3]) console.log(new Uint8Array(idbValidKey[0])); // This is right console.log(idbValidKey[1]); }); }; ``` A full reproduction is attached.
Attachments
Full reproduction
(2.58 KB, text/html)
2025-05-08 07:35 PDT
,
markduckworth
no flags
Details
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2025-05-15 07:36:17 PDT
<
rdar://problem/151384267
>
Ahmad Saleem
Comment 2
2025-05-16 16:33:25 PDT
@Mark - by any chance, you know whether it is recent regression + if it affects any live website on Google?
markduckworth
Comment 3
2025-05-19 08:56:33 PDT
I'm not sure if this is a recent regression in WebKit. We discovered it when improving our test coverage. This affected older versions of the Firestore SDK, so it could affect customers still on those older SDKs with a specific, non-default SDK configuration. Our workaround is to encode byte values in a string, which increases memory use. So we will revisit Uint8Array if/when this is updated in WebKit.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug