Inconsistent state during navigation: `data` (route params) updates before awaited remote query in `$derived`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the bug
When a page uses both data from a route param and an awaited remote query derived from that same param, navigating between instances of the route briefly exposes an inconsistent state: data.symbol already reflects the new
route, while the awaited query result still holds the value from the previous navigation. This produces transient UI glitches and, in keyed {#each} blocks, triggers each_key_duplicate.
Reproduction
Steps:
- Click the
AAPLlink. - Click the
MSFTlink. - Open the console.
Logs
Logging `allSymbols` during the transition:
['MSFT', 'AAPL', 'GOOGL', 'AMZN'] // initial
['AAPL', 'AAPL', 'GOOGL', 'AMZN'] // intermediate — new data.symbol + stale peers
['AAPL', 'MSFT', 'GOOGL', 'AMZN'] // final
And the runtime warning:
Uncaught Svelte error: each_key_duplicate
Keyed each block has duplicate key `AAPL` at indexes 0 and 1
System Info
REPL
Severity
annoyance
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked StackBlitz reproduction, especially src/routes/sym-[symbol]/+page.svelte, and reproduce the AAPL-to-MSFT navigation while watching the console. Trace how the route parameter, data, and awaited remote query in $derived update during navigation. Done means the intermediate inconsistent state and each_key_duplicate warning no longer occur.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100