Skip the initial history write on any activation-key mismatch
When a history entry the router does not own is current at the first
commit, the write-site check correctly declined to treat it as a
restorable traversal — but then fell through to the normal history
write, stamping __NA and the rendered tree onto the foreign entry. The
replay check then saw a restorable entry and dispatched a spurious
restore. And if a further history write landed between the store being
created and that first commit, the write also reverted the entry's URL,
since canonicalUrl is read from location.href when the store is
created.
Skip the write whenever the current entry is not the activation entry:
the render does not describe that entry, so writing to it is wrong
regardless of ownership. Restorability (__NA) still gates only the
replay.
This turns the assertions from the parent commit green. The __NA stamp
is the deterministic half of the damage; reverting the URL needs
another write inside the hydration window, which is why this showed up
as flakiness rather than a failing test.
It was the dominant cause of the back-before-hydration suite's dev
flakiness on CI: an instrumented run showed the false-positive replays
and foreign-entry writes directly, with all five duplicated suite
copies failing beforehand and all five passing on first attempt with
this change (runs 31614244097 and 31618763624 on #97245).
Co-Authored-By:
Claude Fable 5 <noreply@anthropic.com>
Showing
Please
register
or
sign in
to comment