Skip to content

2.37.1 regression: event.data is null in +layout.ts when +page.ts load throws error() #14414

@noaidi

Description

@noaidi

Describe the bug

After upgrading from @sveltejs/[email protected] to 2.37.1, I noticed that if a +page.ts load function throws error(), then in the browser the +layout.ts load function receives event.data as null.

This regression did not occur in 2.37.0 and happens in 2.37.1 and all later versions(2.38.1).

Reproduction

  1. Create src/routes/some/path/+page.js:

    import { error } from '@sveltejs/kit';
    
    export async function load() {
      throw error(404, 'Not found');
    }
  2. In src/routes/+layout.js:

    export async function load(event) {
      console.log('layout data:', event.data); // This should contain the data set in +layout.server.js.
      return {};
    }
  3. Navigate to /some/path in the browser.

Logs

System Info

System:
    OS: macOS 15.6.1
    CPU: (8) arm64 Apple M1
    Memory: 1.84 GB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.7.0 - /opt/homebrew/bin/node
    npm: 11.5.1 - /opt/homebrew/bin/npm
    pnpm: 10.15.1 - /opt/homebrew/bin/pnpm
  Browsers:
    Brave Browser: 140.1.82.161
    Chrome: 140.0.7339.133
    Safari: 18.6
  npmPackages:
    @sveltejs/adapter-vercel: ^5.10.2 => 5.10.2
    @sveltejs/kit: ^2.37.1 => 2.37.1
    @sveltejs/vite-plugin-svelte: ^6.2.0 => 6.2.0
    svelte: ^5.38.10 => 5.38.10
    vite: ^7.1.5 => 7.1.5

Severity

blocking an upgrade

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions