Skip to content

fix(history): detach listeners when startup is interrupted - #119

Merged
vincentkoc merged 2 commits into
mainfrom
fix/history-listener-replay
Nov 20, 2026
Merged

vincentkoc merged 2 commits into
mainfrom
fix/history-listener-replay

Conversation

@vincentkoc

Copy link
Copy Markdown
Member

What Problem This Solves

A history adapter can replay its current location as soon as the router subscribes. If a state subscriber stops the router during that replay, startup throws and leaves the adapter listening. Restarting on the same adapter can leave two listeners attached.

User Impact

Stopping during replay leaves the router idle. Restarting keeps one listener and the replacement start's context. The public API and adapter contract stay the same.

Why This Change Was Made

Each start owns its listener cleanup even when a synchronous callback interrupts registration. Once the adapter returns its unsubscribe function, an interrupted start detaches its own listener and returns.

Evidence

Both regression cases failed on the base revision. Stopping threw a TypeError, and restarting left two live listeners. Both pass with the fix. The full pnpm run check on Node 24.22.1 passed all 75 tests and the installed-tarball smoke test.

@clawsweeper

clawsweeper Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@vincentkoc
vincentkoc marked this pull request as ready for review November 20, 2026 15:58
@vincentkoc
vincentkoc requested a review from a team as a code owner November 20, 2026 15:58
…replay

* origin/main:
  fix(history): replace the URL on an unmatched redirect (#115)
  refactor(tests): consolidate pending invalidation scenarios (#118)
  fix(loading): accept redirect records without a route location as data (#116)
  fix(loading): ignore a component import from before stop (#113)

# Conflicts:
#	CHANGELOG.md
@vincentkoc
vincentkoc merged commit a3937a5 into main Nov 20, 2026
10 checks passed
@vincentkoc
vincentkoc deleted the fix/history-listener-replay branch November 20, 2026 16:03
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.

1 participant