Skip to content

fix(router): honor routeLoader$ id option to avoid wrapper id collisions#8749

Merged
wmertens merged 6 commits into
QwikDev:build/v2from
maiieul:fix-route-loader-id-collision
Jun 19, 2026
Merged

fix(router): honor routeLoader$ id option to avoid wrapper id collisions#8749
wmertens merged 6 commits into
QwikDev:build/v2from
maiieul:fix-route-loader-id-collision

Conversation

@maiieul

@maiieul maiieul commented Jun 19, 2026

Copy link
Copy Markdown
Member

Overview

Loaders defined through a shared wrapper that passes an inline QRL to routeLoader$ — e.g. a withErrorHandling(fn) helper — all share a single optimizer-assigned QRL hash. Since the loader id was derived solely from that hash (loader.__id = loaderQrl.getHash()), every wrapped loader collided on the same __id, and all but the first were silently deduped away in getModuleRouteLoaders. The result: only one of the wrapped loaders ran during SSR and SPA navigation. Plain routeLoader$ calls are unaffected because each is its own lexical QRL with a distinct hash.

Changes

  • Honor the id option (previously marked @deprecated Unused): loader.__id = id ?? loaderQrl.getHash(). Wrappers can now pass a stable, distinct id such as fn.getHash().
  • Dev warning in getModuleRouteLoaders when two distinct loaders share the same id, so this collision surfaces loudly instead of silently dropping loaders.
  • Documented the id option and added a changeset.

Notes

Surfaced while migrating a real app to Qwik v2: a routeLoaderWithErrorHandling helper wrapping routeLoader$ caused only the first loader on each route to run. The app already passed id: fn.getHash(), but the router had stopped honoring it.

I couldn't run the router unit tests in my environment; happy to add a getModuleRouteLoaders dedup/id-override test if you'd like.

Loaders created through a shared wrapper that passes an inline QRL to routeLoader$ all share one optimizer-assigned hash, so they collided on the same __id and all but the first were deduped away in getModuleRouteLoaders. Honor the (previously deprecated) id option so each loader can pass a distinct id (e.g. fn.getHash()), and warn in dev when two loaders share an id.
@maiieul maiieul requested a review from a team as a code owner June 19, 2026 10:02
@changeset-bot

changeset-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 208628f

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

This PR includes changesets to release 5 packages
Name Type
@qwik.dev/router Patch
eslint-plugin-qwik Patch
@qwik.dev/core Patch
create-qwik Patch
@qwik.dev/react 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

@maiieul maiieul self-assigned this Jun 19, 2026
@maiieul maiieul moved this to Waiting For Review in Qwik Development Jun 19, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jun 19, 2026

Copy link
Copy Markdown

Open in StackBlitz

@qwik.dev/core

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/core@8749

@qwik.dev/router

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/router@8749

eslint-plugin-qwik

npm i https://pkg.pr.new/QwikDev/qwik/eslint-plugin-qwik@8749

create-qwik

npm i https://pkg.pr.new/QwikDev/qwik/create-qwik@8749

@qwik.dev/optimizer

npm i https://pkg.pr.new/QwikDev/qwik/@qwik.dev/optimizer@8749

commit: 208628f

@github-actions

github-actions Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor
built with Refined Cloudflare Pages Action

⚡ Cloudflare Pages Deployment

Name Status Preview Last Commit
qwik-docs ✅ Ready (View Log) Visit Preview 208628f

@maiieul maiieul force-pushed the fix-route-loader-id-collision branch from a15f452 to 58f59c9 Compare June 19, 2026 10:27
@maiieul maiieul force-pushed the fix-route-loader-id-collision branch from 58f59c9 to 281c656 Compare June 19, 2026 10:36

@wmertens wmertens left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Note, maybe we're using a hash somewhere instead of loader.__id. Something to look out for.

LGTM

@wmertens wmertens merged commit 267ad80 into QwikDev:build/v2 Jun 19, 2026
48 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting For Review to Done in Qwik Development Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants