Skip to content

Warn when non sveltekit fetch method called in load function #16911

Description

@GoodBoyNinja

Describe the problem

I just spent a few hours debugging a page.server route that worked perfectly fine in local dev but threw an error in production, the route used fetch to get data from an api route, it turns out I forgot to deconstruct the fetch function from the load arguments and accidentally used the global one.

It’s such a small nuance that’s easy to miss and since the code only breaks in production it feels impossible to debug especially on a large repo, typescript doesn’t have any problems with the code since fetch is available globally.

I know that if there was a warning that the fetch function I am using is not the sveltekit one I would fix it in a few seconds rather than hours, so I imagine that if it’s possible to add one, it could be beneficial to other people too.

Describe the proposed solution

“Warning: use sveltekit’s fetch function inside a load function [link to docs]”

Alternatives considered

Dying

Importance

would make my life easier

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    load / layoutneeds-decisionNot sure if we want to do this yet, also design work needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions