refactor(core): show bounded paths in hydration errors - #70249
Conversation
Build expected and actual mismatch descriptions through their respective ancestry so hydration errors identify the precise location without adding DOM validation. Closes angular#56392
|
I'm afraid this change would bring too much noise to the error message, especially for deeply nested hydration issues. Do you have a concrete example where such additional debug information was useful ? |
Keep hydration mismatch snippets local while adding a bounded DOM path that identifies otherwise ambiguous nested branches.
|
Thanks, that is a fair concern. I pushed A concrete ambiguous case is now covered by the integration test. The template contains two otherwise-identical branches: <section aria-label="Account">
<div class="name"><b>Alice</b></div>
</section>
<section aria-label="Billing">
<div class="name"><b>Bob</b></div>
</section>If the and: That identifies the mismatch, but not which identical branch contains it. The revised output keeps those local snippets and adds only this bounded path: The path displays at most four real nodes: the component host plus the three nodes closest to the mismatch. Any middle ancestry is replaced with Would this bounded format address the noise concern? |
|
I think the current proposition lacks in readability. Wondering if we could do something like : Also Maybe there is something the devtools could provide, if we give it the correct info. |
Render bounded hydration paths as vertical trees so deeply nested mismatch locations remain easy to scan in errors and DevTools.
|
Thanks, I updated the output to use the vertical tree format: The cap remains four real nodes in total: the component host plus the three nodes closest to the mismatch. The I also checked the existing DevTools flow. Core already attaches the exact Does the four-node cap look reasonable to you? |
PR Checklist
PR Type
What is the current behavior?
Hydration mismatch errors describe the mismatched node and its immediate parent. When multiple branches have the same local structure, that snippet does not identify which branch in the component template contains the mismatch.
Issue Number: #56392
What is the new behavior?
Hydration mismatch errors retain the compact local expected and actual DOM snippets and add a bounded
DOM path:...;The integration test uses two otherwise-identical nested branches,
AccountandBilling. The local snippets are the same, while the bounded path identifies theBillingbranch without rendering the full ancestry tree.The change only improves development-mode diagnostics. It does not add DOM validation, recognize specific mismatch patterns, or change when hydration reports a mismatch.
Does this PR introduce a breaking change?
Other information
No documentation update is needed because this change does not introduce or modify a public API.
Tested with:
pnpm bazel test //packages/platform-server/test:test