Skip to content

routeId not tracked as dependency to layout load #6980

Description

@geoffrich

Describe the bug

When you access event.routeId in a layout load function, the load function does not re-run when routeId changes. Since routeId is based on the URL, we should track dependencies to it similar to url and params.

This probably only makes sense in a layout load. On page loads, routeId should stay the same.

Reproduction

StackBlitz

  1. Load page. Notice routeId for the current page is displayed
  2. Navigate to another page. The routeId does not change until a page reload

In this case you could work around the issue by retrieving it from the $page store, but if you're doing something else with routeId, that would not be re-run.

// +layout.server.js
export const load = ({routeId}) => {
  return {
    routeId
  }
}

Logs

n/a

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (4) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.17.0 - /usr/local/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.80 
    @sveltejs/kit: next => 1.0.0-next.499 
    svelte: ^3.46.0 => 3.50.1 
    vite: ^3.1.0 => 3.1.3

Severity

serious, but I can work around it

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions