fix: apply in-page channel codecs to shared state - #370
Conversation
|
@posva is attempting to deploy a commit to the NuxtLabs Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
◈ PR Lens
Architecture 1 component touched across 2 lanes. Data flow
Drill down
|
There was a problem hiding this comment.
🟢 Approval recommended
The change consistently applies existing codec semantics to shared-state traffic and includes regression coverage for the previously inconsistent paths.
Pull request overview
This PR fixes an inconsistency in the in-page channel’s serialization pipeline where shared-state traffic bypassed endpoint codec hooks in some paths, leading to incorrect behavior (e.g., double-deserialization) when panels subscribe after the page script has already established state.
Changes:
- Apply
serializeto shared-state outbound payloads (snapshots, full-state updates, patch arrays) before sending across the port. - Route shared-state inbound handlers through the same
createLocalFunctionRegistry(codec)receive pipeline sodeserializeis applied consistently. - Add regression tests covering patch-based vs full-state update flows through both endpoint codecs, plus a targeted snapshot/notification deserialization test.
File summaries
| File | Description |
|---|---|
| packages/devframe/src/in-page-channel/panel.ts | Ensures shared-state requests/events use serializeArgs and shared-state handlers resolve via a codec-aware local function registry. |
| packages/devframe/src/in-page-channel/page-script.ts | Applies codec serialization to shared-state notifications and routes per-peer shared-state handlers through a codec-aware registry. |
| packages/devframe/src/in-page-channel/in-page-channel.test.ts | Adds regression tests verifying shared-state snapshots/updates/patches round-trip through both endpoint codecs. |
| docs/content/1.guide/12.in-page-channel.md | Documents that codec hooks also apply to shared-state snapshots, full-state updates, and patch arrays (and notes deep restoration considerations). |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Shared-state updates in the in-page channel skipped the codec hooks, even though subscription snapshots passed through
deserialize. Applyserializeanddeserializeconsistently to snapshots, full-state updates, and patches in both directions, with regression tests for each path.I found this in pinia colada devtools where opening the devtools after the app was running was yielding double-deserialization on the data and after digging a bit, it turned out to be within devframe but I could be wrong.
This is the commit that is meant to be a workaround this bug: posva/pinia-colada@86e8ebf