Skip to content

Inconsistent state during navigation: data (route params) updates before awaited remote query in $derived #15860

@MartkCz

Description

@MartkCz

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

https://stackblitz.com/edit/sveltejs-kit-template-default-gzoodfhc?embed=1&file=src%2Froutes%2Fsym-%5Bsymbol%5D%2F%2Bpage.svelte

Steps:

  1. Click the AAPL link.
  2. Click the MSFT link.
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions