Skip to content

fix(query): hand a preloaded entry over to a navigation read once - #742

Merged
ryansolid merged 1 commit into
solidjs:mainfrom
dipankarmaikap:fix/query-preload-handoff-abandoned-flights
Nov 20, 2026
Merged

ryansolid merged 1 commit into
solidjs:mainfrom
dipankarmaikap:fix/query-preload-handoff-abandoned-flights

Conversation

@dipankarmaikap

@dipankarmaikap dipankarmaikap commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

A query() entry fetched under preload intent (hover/focus link preload) is later consumed by a real read under navigate intent. The reuse branch performed that handoff on every read:

if (cached[3] === "preload" && intent !== "preload") {
  cached[0] = now;         // fresh Date.now() on every read
}
...
cached[4][0]();            // reading scope tracks the version signal
...
cached[4][1](cached[0]);   // ...then a NEW value is written into it

cached[3] is never updated, so each navigate-intent read bumps the stamp to a new Date.now() and writes it to the very signal the reading memo just tracked. The memo self-notifies, re-runs on the next flush pass, hits the same branch, bumps again… until the ms clock repeats a value and the equal write becomes a no-op. Each re-run re-adopts the still-pending preload promise, so dev attribution counts it as a superseded flight:

[ABANDONED_FLIGHTS] "user" abandoned 3 flights in 1000ms: each was superseded by the
next before it landed, so every input asked again and the answers were discarded. …
in <Document> › … › <User> › user

This reproduces on the solid-v2/fullstack template with no modifications: run the dev server, then on /users rest the pointer on a user link for a moment (the preload starts) and click. Whenever the preload fetch is still in flight at click time — first hit in dev while the server function compiles, or any throttled network — the console warns for both the user and me memos on /users/:id, and whyDidRun shows each re-running 5–8 times within ~10 ms. A direct click without a preceding hover never hits the branch, which is why the warning looks sporadic.

The fix is to perform the handoff once: bump the stamp, record it on the entry (cached[3] = intent), and update the version signal before the current read tracks it. Other consumers still learn the preload was consumed; the scope performing the handoff no longer notifies itself. The non-handed navigate write stays as it was (equal value, so a no-op) — nothing changes for entries not flagged "preload", and the bundled dist/ copies in the published package build from this source either way.

After the fix the consuming memos run exactly once per navigation — the template's /users/:id page navigates with no warnings and no re-runs in the capture window.

vitest run passes 761/761 and test:types is clean.

@changeset-bot

changeset-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2a5ec09

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/router Patch

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

@dipankarmaikap
dipankarmaikap marked this pull request as draft November 19, 2026 18:50
A read with non-preload intent consuming a cache entry fetched under
preload intent bumped the entry stamp on every read and wrote that fresh
stamp to the entry's version signal after the reading scope had already
tracked it. The reading memo re-ran per flush pass, re-adopted the
still-pending preload promise, and dev attribution reported the
superseded flights as ABANDONED_FLIGHTS.

Record the handoff on the entry (cached[3] = intent) so it happens once,
and update the version signal before the current read tracks it — the
bump still notifies other consumers, but no longer the reader performing
the handoff.
@dipankarmaikap
dipankarmaikap force-pushed the fix/query-preload-handoff-abandoned-flights branch from 430aa0f to 2a5ec09 Compare November 19, 2026 18:54
@dipankarmaikap
dipankarmaikap marked this pull request as ready for review November 19, 2026 18:59
@ryansolid
ryansolid merged commit aae9ba5 into solidjs:main Nov 20, 2026
4 checks passed
ryansolid added a commit that referenced this pull request Nov 20, 2026
…ce (#739) (#743)

Regression test from #740. It fails before #742 (the memo ran 5 times)
and passes after it.



Claude-Session: https://claude.ai/code/session_0117BoWMR7ndYUnqBW5NjTbC

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Roel Bruggink <roel@jaroel.nl>
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.

2 participants