Skip to content

7.8.2 is not respecting the _routes param for data requests with middleware enabled #14285

@rossipedia

Description

@rossipedia

Reproduction

Reproduction repo: https://github.com/rossipedia/rr-data-req-loaders-shenanigans

Instructions are in the README, but I've duplicated them here:


Reproduction steps:

Start this application with npm run dev

Execute the following request via curl:

$ curl 'localhost:5173/foo

You should see the following output in the server terminal:

root loader
layout loader
foo loader

Now run the following curl command to send a RR Data request for the routes/foo route only:

$ curl 'localhost:5173/foo.data?_routes=routes%2Ffoo'

You will notice that you still see

root loader
layout loader
foo loader

This is the bug.

When requesting data for a specific set of routes, only those route loaders should execute.

Instead, all the matched route loaders are invoked, based on the request's pathname, and the _routes parameter is ignored.

System Info

System:
    OS: macOS 15.6.1
    CPU: (16) arm64 Apple M4 Max
    Memory: 7.30 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.15.1 - ~/.local/state/fnm_multishells/3342_1756931003739/bin/node
    Yarn: 4.9.1 - ~/.local/state/fnm_multishells/3342_1756931003739/bin/yarn
    npm: 10.9.2 - ~/.local/state/fnm_multishells/3342_1756931003739/bin/npm
    bun: 1.2.21 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 139.0.7258.155
    Edge: 139.0.3405.119
    Safari: 18.6

Used Package Manager

npm

Expected Behavior

I expect the loaders for only the specified routes to be run.

Actual Behavior

All loaders for all matched routes based on pathname are run, and the _routes param is ignored.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions