Skip to content

fix(bridge): serialize Map and Set entries during inspection (#43) - #175

Merged
andykog merged 2 commits into
mobxjs:masterfrom
eldertek:fix/issue-43-serialize-map-set-entries
Nov 29, 2026
Merged

andykog merged 2 commits into
mobxjs:masterfrom
eldertek:fix/issue-43-serialize-map-set-entries

Conversation

@eldertek

Copy link
Copy Markdown
Contributor

Fixes #43.

Serializes \Map/\ObservableMap\ and \Set/\ObservableSet\ entries recursively inside \serialize()\ in \src/Bridge.js\ so inspected map entries clone cleanly across \window.postMessage, while updating \src/backend/utils/inspector.js\ path lookup to traverse into \symbols.entries.

Verification:

  • Added unit tests in \src/Bridge-test.js\ covering \ObservableMap\ serialization, self-referential \Map/\Set\ handling, and nested entry path traversal.
  • Ran
    pm run test:unit\ (9 passing) and verified
    pm run build:chrome\ and
    pm run build:firefox.

@andykog

andykog commented Nov 29, 2026

Copy link
Copy Markdown
Member

Thanks for the contribution!

@andykog
andykog merged commit e90dcf1 into mobxjs:master Nov 29, 2026
1 check passed
andykog added a commit that referenced this pull request Nov 29, 2026
…e crashes found (#177)

PR #175 fixed how the backend sends map and set entries, but no test
opened real values in the panel. This PR adds an e2e test for that. The
test opens hard-to-inspect values in the Changes tab, expands every row
and compares each row with the real object in the page. It found four
bugs, and this PR fixes them.

## Key changes
- New playground page `inspect-fixtures`. Its test values are in
`test/fixtures/trickyValues.js`: primitives, functions, class instances,
MobX containers, maps with keys of any type, sets of objects, cycles and
deep nesting.
- New e2e test `test/e2e/inspectFixtures.js`. For each value, it checks
that no uncaught error occurs and that every expand gets its inspect
result. It also checks each row against the real object: map keys, set
size, array indexes, object keys and primitive values. A unit test sends
the same values through serialize, structured clone and deserialize.
- Fix: a map key or set entry that was not a string or a number crashed
the panel. The panel used it as the row name. `DataView` now shows a
short label for it, for example `Point{…}`, `Symbol(key)` or
`namedFn()`.
- Fix: a value that contains itself, such as a map that holds itself,
opened inside itself forever (React error #185). `DataItem` no longer
opens a row by itself when its value is also the value of a parent row.
- Fix: since the React 18 upgrade (#173), a click on a value popover or
in it also toggled the log item behind it. The popover is a portal, so
React click events from it reach the log item. When the log item opened,
its details replaced the inspected value, and the popover showed a
spinner forever. `Popover` now stops these clicks, as the popover did
before #173.
- Data attributes on `DataItem`, `Spinner` and the popover trigger, so
that the test can find rows. They do not change behavior.
- Fix: Chrome sends extension messages as JSON, so `undefined` keys
disappeared, `NaN` and `Infinity` showed as `null`, and a BigInt stopped
the whole message. `serialize()` now sends these values as markers, and
`deserialize()` turns them back into values. The panel shows a BigInt as
`10n`.
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.

Changes tab, ObservableMap open error.

2 participants