fix(#209): cdp_mmkv delete + boolean get against the real Nitro hybrid-object API#287
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cdp_mmkvwithaction: deletethrewmmkv.delete is not a functionon the Nitro react-native-mmkv line (reported 7/8 times in one session, forcing a rawcdp_evaluateescape hatch for every iOS auth logout) — GH #209.Root cause (verified against the published package source —
src/specs/MMKV.nitro.ts+cpp/HybridMMKV.cpp):buildMmkvExpressionwas written against react-native-mmkv's JS wrapper class API (delete(key)), but the generated expression executes against the raw Nitro hybrid object returned bycreateHybridObject('MMKVFactory').createMMKV(...), whose spec exposesremove(key): boolean— there is nodelete().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:
getwithtype: 'boolean'emittedmmkv.getBool(key), which exists on no MMKV surface — the wrapper, the v3 wrapper, and the v4 hybrid object all spell itgetBoolean. Broken since the tool shipped (GH #59).Fix
In the generated Hermes expression (
scripts/cdp-bridge/src/tools/mmkv.ts):remove()(the hybrid-object spec name), fall back todelete()for wrapper-shaped objects (e.g. aglobalThis.__MMKV__escape hatch), and return a named__agent_error("neither remove() nor delete()") instead of a bare TypeError when neither exists.getBoolean.Verification
gh-209-mmkv-nitro-api.test.jsrun the generated expression in anode:vmsandbox against a spec-faithful v4 mock (remove/getBooleanpresent,delete/getBoolabsent), each watched fail first. 2 stale shape assertions ingh-59-7updated (they pinned the buggy method names).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