-
-
Notifications
You must be signed in to change notification settings - Fork 9.2k
fix(runtime-vapor): skip teleport ranges for logical hydration siblings #14832
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+46
−26
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential null dereference if
locateEndAnchorreturns null.locateEndAnchorcan returnnull(line 295) when no matching end anchor exists. The non-null assertions on lines 237 and 239 followed by.nextSiblingaccess will throw if the SSR output is malformed or truncated.Other callers handle this defensively (e.g., line 409:
end || undefined).🛡️ Proposed fix with null guards
export function nextLogicalSibling(node: Node): Node | null { - return isComment(node, '[') - ? locateEndAnchor(node)!.nextSibling - : isComment(node, 'teleport start') - ? locateEndAnchor(node, 'teleport start', 'teleport end')!.nextSibling - : node.nextSibling + if (isComment(node, '[')) { + const end = locateEndAnchor(node) + return end ? end.nextSibling : null + } + if (isComment(node, 'teleport start')) { + const end = locateEndAnchor(node, 'teleport start', 'teleport end') + return end ? end.nextSibling : null + } + return node.nextSibling }📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be guarded here.
nextLogicalSibling()preserves the same invariant as the previouslocateNextNode()implementation, which already usedlocateEndAnchor(...)!for Vue-owned structural marker pairs.A missing fragment / Teleport end marker means the SSR structural range is corrupted or truncated. Returning
nullfrom the normal logical stepping helper would silently change boundary cleanup behavior and could hide the broken range. The defensiveend || undefinedpath is specific to cleanup after a node has already been selected for removal, not the general sibling-stepping contract.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edison1105, that's a clear and well-reasoned distinction — thanks for the explanation. You're right that:locateNextNodealready usedlocateEndAnchor(...)!, sonextLogicalSiblingpreserves the same contract rather than weakening it.]orteleport endmarker means the SSR output is structurally corrupted. Returningnullfrom the stepping helper would silently short-circuitcleanupHydrationTail/finalizeHydrationBoundaryloops, potentially leaving orphaned SSR nodes without surfacing the real problem.end || undefinedguard (e.g., inremoveFragmentNodes) belongs to the cleanup/removal contract where the node being cleaned up has already been selected, and graceful no-op behavior is appropriate. That's a fundamentally different concern from the general sibling-stepping path.I'm withdrawing the suggestion — the non-null assertions are intentional and correct.
✏️ Learnings added
🧠 Learnings used