Repository navigation
Conversation
A pending debounced search-param write can overwrite the URL restored by Back and remove the Forward entry. Cancel the pending batch on popstate and remove its listener when the batch flushes normally. Two regression cases reproduce different-path and same-path navigation. Both fail before the fix; all 157 Atom tests pass afterward. A framework-free Chromium history probe also preserves the restored query after the change. Native debounce and normal history writes retain their existing behavior.
🦋 Changeset detectedLatest commit: 045818c The changes in this PR will be included in the next version bump. This PR includes changesets to release 35 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
After Back cancels a pending raw and schema-backed batch, another page write must preserve the restored search text. This regression verifies that cancelled values cannot reappear in a later batch. All157Atomtests, lint and type checks pass.
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
…ng cancellation listener
This branch is waiting to be deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #10582.
Closes EFF-3700.
Typing a URL filter and pressing Back during
Atom.searchParam's 500ms debounce currently overwrites the restored query when the pending timer runs. The atom has already read the restored value, so the displayed filter and URL disagree, and the stale push drops the Forward entry.Change
A
popstatelistener discards the pending batch. It is registered before any search-param reader's ownpopstatelistener and stays registered while a reader is mounted or a batch is pending, so it always runs first. Window dispatches in registration order, which means stale writes are gone before atom observers run and a write an observer makes in response to the navigation is kept. Capture priority does not give this ordering on Window, so it is not used.Readers remain individual native listeners, as on
main. The browser isolates their failures, so a throwing observer cannot stop other parameters from restoring.A write now sets up its batch (pending value, cancellation listener, timer) before publishing the value. Synchronous observers that dispose the registry, write again, throw, or navigate therefore see a complete batch.
This covers raw and schema-backed parameters together, including traversal between entries on the same pathname. The debounce and ordinary writes are unchanged. Router navigation through
pushStatewithout an event is out of scope.This isolates one independently reproduced concern from closed, unmerged Effect-TS/effect-smol#2382, without its router-specific history state changes. Merged #8820 fixed the separate URL hash and empty-query issues.
Verification
pnpm test --run packages/effect/test/reactivity/Atom.test.ts: 162 tests pass. The new cases fail againstmainand against each rejected intermediate approach (late or capture-phase cancellation, a shared dispatcher without failure isolation, publishing before the batch is set up).history.back()/history.forward(): stale raw and schema writes are cancelled with no push and Forward still works; an observer that normalizes the restored value produces exactly one push; throwing observers are each reported while every reader still restores; disposal, nested writes and exceptions during the initial write keep cancellation; nopopstatelistener is left onwindowafter disposal.pnpm lintandpnpm checkpass.Prepared with assistance from OpenAI Codex.