fix(dexie-cloud-addon): add .key/.primaryKey getters to createBlobResolvingCursor (fixes cursor crash) - #2293
Conversation
…olvingCursor Object.create() cursor wrappers must explicitly override .key and .primaryKey with closure-based getters. Without them, native IDBCursorWithValue getters are reached through the prototype chain with wrong 'this', causing 'TypeError: Illegal invocation' in Chrome 146+. All other cursor wrappers in Dexie core (virtualIndexMiddleware, liveQuery tracking) already do this correctly — this fixes the missing case in blobResolveMiddleware. Fixes: #2292 Bumps: dexie-cloud-addon 4.4.9 → 4.4.10
📝 WalkthroughWalkthroughThis PR bumps dexie-cloud-addon from version 4.4.9 to 4.4.10 and fixes a Chrome 146+ compatibility issue where accessing Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
addons/dexie-cloud/src/middlewares/blobResolveMiddleware.ts (1)
202-215: Consider extracting a shared cursor-wrapper helper.This safety pattern (
key/primaryKey/valueown descriptors) is important and easy to drift; centralizing it would reduce future regressions.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@addons/dexie-cloud/src/middlewares/blobResolveMiddleware.ts` around lines 202 - 215, Extract the cursor-wrapping pattern into a shared helper (e.g., wrapIDBCursor or createWrappedCursor) and replace the inline Object.create(...) usage in blobResolveMiddleware with a call to it; the helper should accept the native cursor and return Object.create(cursor, { key: { get() { return cursor.key; }, configurable: true }, primaryKey: { get() { return cursor.primaryKey; }, configurable: true }, value: { get() { return cursor.value; }, configurable: true } }) so the same safety guarantees are preserved, export the helper for reuse, and update any other places that construct wrapped cursors to call this new helper.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@addons/dexie-cloud/src/middlewares/blobResolveMiddleware.ts`:
- Around line 202-215: Extract the cursor-wrapping pattern into a shared helper
(e.g., wrapIDBCursor or createWrappedCursor) and replace the inline
Object.create(...) usage in blobResolveMiddleware with a call to it; the helper
should accept the native cursor and return Object.create(cursor, { key: { get()
{ return cursor.key; }, configurable: true }, primaryKey: { get() { return
cursor.primaryKey; }, configurable: true }, value: { get() { return
cursor.value; }, configurable: true } }) so the same safety guarantees are
preserved, export the helper for reuse, and update any other places that
construct wrapped cursors to call this new helper.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 5e9a318a-5db7-4de4-a856-83f982e8b001
📒 Files selected for processing (2)
addons/dexie-cloud/package.jsonaddons/dexie-cloud/src/middlewares/blobResolveMiddleware.ts
Problem
createBlobResolvingCursor()wraps cursors viaObject.create(cursor, ...)but only overrides.valueand.start— not.keyor.primaryKey. When these properties are accessed, the prototype chain eventually reaches the nativeIDBCursorWithValuegetter withthispointing to the wrapper object, causingTypeError: Illegal invocation.All other cursor wrappers in Dexie core (
virtualIndexMiddleware, liveQuery tracking) already override.keyand.primaryKeycorrectly. This was the missing case.Fix
Add closure-based
.keyand.primaryKeygetters to theObject.create()descriptor increateBlobResolvingCursor():Version bump
dexie-cloud-addon: 4.4.9 → 4.4.10
References
Fixes #2292
Reported by ToToDo team
Summary by CodeRabbit
Bug Fixes