Skip to content

fix(#209): cdp_mmkv delete + boolean get against the real Nitro hybrid-object API#287

Merged
Lykhoyda merged 1 commit into
mainfrom
fix/209-mmkv-nitro-remove
Jun 13, 2026
Merged

fix(#209): cdp_mmkv delete + boolean get against the real Nitro hybrid-object API#287
Lykhoyda merged 1 commit into
mainfrom
fix/209-mmkv-nitro-remove

Conversation

@Lykhoyda

Copy link
Copy Markdown
Owner

Summary

cdp_mmkv with action: delete threw mmkv.delete is not a function on the Nitro react-native-mmkv line (reported 7/8 times in one session, forcing a raw cdp_evaluate escape hatch for every iOS auth logout) — GH #209.

Root cause (verified against the published package source — src/specs/MMKV.nitro.ts + cpp/HybridMMKV.cpp): buildMmkvExpression was written against react-native-mmkv's JS wrapper class API (delete(key)), but the generated expression executes against the raw Nitro hybrid object returned by createHybridObject('MMKVFactory').createMMKV(...), whose spec exposes remove(key): boolean — there is no delete().

Version-label correction vs the issue: stable v3 (3.0.0–3.3.3) is TurboModule-based — no Nitro at all — and defaultMMKVInstanceId (used in the reporter's working workaround) exists only in the v4 factory spec. The affected surface is v4 / the 3.0 betas; the fix targets the API surface, not a version number.

Second latent bug found during verification: get with type: 'boolean' emitted mmkv.getBool(key), which exists on no MMKV surface — the wrapper, the v3 wrapper, and the v4 hybrid object all spell it getBoolean. Broken since the tool shipped (GH #59).

Fix

In the generated Hermes expression (scripts/cdp-bridge/src/tools/mmkv.ts):

  • delete: prefer remove() (the hybrid-object spec name), fall back to delete() for wrapper-shaped objects (e.g. a globalThis.__MMKV__ escape hatch), and return a named __agent_error ("neither remove() nor delete()") instead of a bare TypeError when neither exists.
  • boolean get: getBoolean.

Verification

  • TDD: 4 new tests in gh-209-mmkv-nitro-api.test.js run the generated expression in a node:vm sandbox against a spec-faithful v4 mock (remove/getBoolean present, delete/getBool absent), each watched fail first. 2 stale shape assertions in gh-59-7 updated (they pinned the buggy method names).
  • Full suite: 2023/2023.
  • Multi-LLM review (Codex + Antigravity): both SHIP, each independently confirming the API names against published react-native-mmkv v2.12.2 / v3.3.3 / v4.3.1 source, ES5 validity + escaping in all branches, and remove-before-delete unambiguity.
  • No live-device run: the workspace test-app doesn't bundle react-native-mmkv (a Nitro native module needs a Dev Client rebuild — out of scope). The VM tests model the exact published spec surface.

The issue's second ask — a clearKeys: action-YAML directive for self-contained auth-gated replays — is split to follow-up #286.

Closes #209

🤖 Generated with Claude Code

…d-object API

buildMmkvExpression was written against react-native-mmkv's JS wrapper
class API, but the expression executes against the RAW Nitro hybrid
object from createHybridObject('MMKVFactory').createMMKV(...). Ground
truth from the published package (v4.3.1 src/specs/MMKV.nitro.ts +
cpp/HybridMMKV.cpp): the hybrid object exposes remove(key): boolean —
no delete(). Hence "mmkv.delete is not a function" on every delete
(reported 7/8 times in one session; forced a raw cdp_evaluate escape
hatch for each iOS logout).

Version-label correction vs the issue: stable v3 (3.0.0-3.3.3) is
TurboModule-based — no Nitro at all; defaultMMKVInstanceId (used in the
reporter's working workaround) exists only in the v4 factory spec. The
affected line is v4 / 3.0-betas; the fix targets the API surface, not a
version number.

Second latent bug found during verification: get type=boolean emitted
mmkv.getBool(key), which exists on NO surface (wrapper and hybrid object
both spell it getBoolean) — broken since the tool shipped (GH #59).

Fix in the generated expression:
- delete: prefer remove() (spec name), fall back to delete()
  (wrapper-shaped objects), named __agent_error when neither exists.
- get boolean: getBoolean.

Tests: 4 new in gh-209-mmkv-nitro-api.test.js running the expression in
a VM against a spec-faithful v4 mock (remove/getBoolean present,
delete/getBool absent), watched fail first; 2 stale shape assertions in
gh-59-7 updated (they pinned the bug). Suite: 2023/2023.

The issue's clearKeys: action-YAML enhancement is split to #286.

Closes #209

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Lykhoyda Lykhoyda merged commit 0386204 into main Jun 13, 2026
10 checks passed
@Lykhoyda Lykhoyda deleted the fix/209-mmkv-nitro-remove branch June 13, 2026 09:06
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: cdp_mmkv delete fails on Nitro MMKV v3 (API is remove, not delete) — blocks first-class storage/auth reset

1 participant