Skip to content

False positive fetch warning when using a remote function in a universal load function #15283

@teemingc

Description

@teemingc

Describe the bug

I'm using a remote function to check if an album exists based on the provided album ID in the route param /album/[id]. If the album doesn't exist for the given ID, I'd like to throw a 404 or simply redirect the user back to the album list page. However, doing so falsely warns me to use the load function provided fetch instead of window.fetch

Reproduction

https://stackblitz.com/edit/sveltejs-kit-template-default-kuxkz1cy?file=src%2Froutes%2Falbums%2F%5Bid%5D%2Falbums.remote.js

  1. Open your browser console
  2. Navigate from the home page to the album page from the nav bar.
  3. Observe the warning about using window.fetch

Logs

Loading /_app/remote/go4pcy/getAlbum?payload=WyI4SkI3cFNSc3JEbTFLcTZ3b0JhcEIiXQ using `window.fetch`. For best results, use the `fetch` that is passed to your `load` function: https://svelte.dev/docs/kit/load#making-fetch-requests
warn @ client.js?v=ba405339:3209
window.fetch @ fetcher.js?v=ba405339:55
remote_request @ shared.svelte.js?v=ba405339:10
(anonymous) @ query.svelte.js?v=ba405339:29
#run @ query.svelte.js?v=ba405339:233
Query @ query.svelte.js?v=ba405339:204
(anonymous) @ query.svelte.js?v=ba405339:23
(anonymous) @ shared.svelte.js?v=ba405339:77
load @ +page.ts:5
load_node @ client.js?v=ba405339:873
await in load_node
(anonymous) @ client.js?v=ba405339:1122
load_route @ client.js?v=ba405339:1093
_preload_data @ client.js?v=ba405339:524
preload @ client.js?v=ba405339:1928
await in preload
(anonymous) @ client.js?v=ba405339:1873
setTimeout
(anonymous) @ client.js?v=ba405339:1872Understand this warning

System Info

System:
    OS: macOS 26.2
    CPU: (8) arm64 Apple M1 Pro
    Memory: 70.19 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.13.0 - /Users/teeming/Library/pnpm/node
    Yarn: 3.2.3 - /Users/teeming/Library/pnpm/yarn
    npm: 11.6.2 - /Users/teeming/Library/pnpm/npm
    pnpm: 10.28.2 - /Users/teeming/Library/pnpm/pnpm
    bun: 1.3.6 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 144.0.7559.133
    Chrome Canary: 135.0.7048.0
    Firefox: 144.0
    Firefox Developer Edition: 130.0
    Safari: 26.2
    Safari Technology Preview: 26.0
  npmPackages:
    @sveltejs/adapter-cloudflare: ^7.2.6 => 7.2.6 
    @sveltejs/kit: ^2.50.1 => 2.50.2 
    @sveltejs/vite-plugin-svelte: ^6.2.4 => 6.2.4 
    svelte: ^5.48.2 => 5.49.2 
    vite: ^7.3.1 => 7.3.1

Severity

annoyance

Additional Information

In retrospect, this is probably the wrong way to do this. Maybe I should simply do the redirect in the component itself? Or separate the data fetching logic from the remote function and reuse that directly in a server load function? I thought doing the redirect in the load function would be more performant because then it doesn't need download and render the component code just to redirect

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedPRs welcomed. The implementation details are unlikely to cause debateready to implementplease submit PRs for these issues!

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions