Skip to content

fix(dexie-cloud-addon): add .key/.primaryKey getters to createBlobResolvingCursor (fixes cursor crash) - #2293

Merged
dfahlander merged 1 commit into
masterfrom
liz/fix-blob-resolve-cursor-getters
Apr 4, 2026
Merged

fix(dexie-cloud-addon): add .key/.primaryKey getters to createBlobResolvingCursor (fixes cursor crash)#2293
dfahlander merged 1 commit into
masterfrom
liz/fix-blob-resolve-cursor-getters

Conversation

@liz709

@liz709 liz709 commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Problem

createBlobResolvingCursor() wraps cursors via Object.create(cursor, ...) but only overrides .value and .start — not .key or .primaryKey. When these properties are accessed, the prototype chain eventually reaches the native IDBCursorWithValue getter with this pointing to the wrapper object, causing TypeError: Illegal invocation.

All other cursor wrappers in Dexie core (virtualIndexMiddleware, liveQuery tracking) already override .key and .primaryKey correctly. This was the missing case.

Fix

Add closure-based .key and .primaryKey getters to the Object.create() descriptor in createBlobResolvingCursor():

key: { get() { return cursor.key; }, configurable: true },
primaryKey: { get() { return cursor.primaryKey; }, configurable: true },

Version bump

dexie-cloud-addon: 4.4.9 → 4.4.10

References

Fixes #2292
Reported by ToToDo team

Summary by CodeRabbit

Bug Fixes

  • Fixed cursor property access handling to ensure compatibility with Chrome 146+.

…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
@coderabbitai

coderabbitai Bot commented Apr 4, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR bumps dexie-cloud-addon from version 4.4.9 to 4.4.10 and fixes a Chrome 146+ compatibility issue where accessing key or primaryKey properties on wrapped cursors in createBlobResolvingCursor() triggered "Illegal invocation" errors from native IndexedDB getters called with incorrect this context.

Changes

Cohort / File(s) Summary
Package Version
addons/dexie-cloud/package.json
Incremented package version from 4.4.9 to 4.4.10.
Cursor Property Accessors
addons/dexie-cloud/src/middlewares/blobResolveMiddleware.ts
Added explicit key and primaryKey getter descriptors to the wrapped cursor object created in createBlobResolvingCursor(). The closure-based getters capture the original cursor, preventing prototype chain lookup from reaching native IDBCursorWithValue getters with a wrong this binding.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

🐰 A cursor wrapped in layers deep,
Chrome 146 made promises to keep—
"Call me right, with proper this!" it cried,
So closures captured—bugs brushed aside.
🔧✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title directly describes the main fix: adding .key/.primaryKey getters to createBlobResolvingCursor to fix a cursor crash, matching the core change in the codebase.
Linked Issues check ✅ Passed The PR fully implements the required fix from issue #2292: adds closure-based getters for .key and .primaryKey to createBlobResolvingCursor and bumps the version appropriately.
Out of Scope Changes check ✅ Passed All changes are in scope: the blobResolveMiddleware.ts implements the core fix for issue #2292, and the version bump in package.json is a standard follow-up for releasing the patched version.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch liz/fix-blob-resolve-cursor-getters

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 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/value own 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2d92a26 and dac3942.

📒 Files selected for processing (2)
  • addons/dexie-cloud/package.json
  • addons/dexie-cloud/src/middlewares/blobResolveMiddleware.ts

@dfahlander
dfahlander merged commit 97f9942 into master Apr 4, 2026
7 checks passed
@dfahlander
dfahlander deleted the liz/fix-blob-resolve-cursor-getters branch April 4, 2026 11:07
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

Successfully merging this pull request may close these issues.

bug: Illegal invocation on IDB cursor in Chrome 146+ (createBlobResolvingCursor missing .key/.primaryKey)

2 participants