Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

Error handling in preload  #1125

Open
Open
@artecoop

Description

@artecoop

Describe the bug
On a sapper project, imagine having a test.svelte file with this content:

<script context="module">
    import gql from 'graphql-tag';
    import client from '../../graphql';

    export async function preload(page, session) {
        const GETPROFILE = gql`
            query($fid: ID!) {
                profile(fid: $fid) {
                    email
                    completename
                }
            }
        `;

        const profile = await client.query({ query: GETPROFILE, variables: { fid: 'FOOOO' } });
        return { profile };
    }
</script>

<script>
    export let profile;
</script>

<span>Welcome {profile.completename}</span>

If I NAVIGATE from any other page to this one by clicking a link and the grapqhl endpoint somewhat returns an error, the page correctly show the error and the related message (via _error.svelte).
But if I REFRESH (or open a new tab and use the same exact url) the page, sapper flashes for a second the error and then show the normal flow for the page, as no error occurred.

Information about your Sapper Installation:

  • Your browser and the version: Agnostic

  • Your operating system: Fedora 31

  • Your hosting environment: Local development

  • Sapper version 0.27.10

  • Svelte version 3.20.1

  • If it is an exported (npm run export) or dynamic application: its under npm run dev

  • Whether your application uses Webpack or Rollup: Rollup

Severity
Well, I can workaround on a specific page of a specific project. But I can't be always this lucky.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions