Skip to content

Handle missing component CIDs in resolve_components_xrefs#4166

Open
lunks wants to merge 1 commit intophoenixframework:mainfrom
lunks:fix-resolve-components-xrefs-crash
Open

Handle missing component CIDs in resolve_components_xrefs#4166
lunks wants to merge 1 commit intophoenixframework:mainfrom
lunks:fix-resolve-components-xrefs-crash

Conversation

@lunks
Copy link

@lunks lunks commented Mar 13, 2026

resolve_components_xrefs/2 crashes with CaseClauseError when a component CID
is removed between diff cycles but still referenced via :s cross-reference pointers.
This can happen during stream resets where components are removed and re-added across
two diff cycles, leaving stale CID references.

Three cases are now handled gracefully instead of crashing:

  • Cross-reference target CID was removed from the components map
  • Chain of cross-references (CID 3 → CID 2 → CID 1) where recursive resolution
    removes the intermediate target
  • CID referenced in the rendered tree but missing from the components map entirely

Related to #1247.

resolve_components_xrefs/2 crashes with CaseClauseError when a
component CID is removed between diff cycles (e.g. during stream
resets) but still referenced via cross-reference pointers.

This handles three cases: direct missing target, chain resolution
where the intermediate target is removed recursively, and CID
missing from the components map entirely.

Related to phoenixframework#1247.
@SteffenDE
Copy link
Collaborator

It feels like this does not solve the underlying problem, but instead treats the symptoms. If LiveView thinks it can reuse the component's statics, it seems reasonable to fail if it cannot as that's unexpected. The fix should be to ensure that LiveView cannot reuse a stale component in a diff. Do you have something that consistently reproduces this?

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.

2 participants