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

segment prop is initially incorrect on client-side layout for server-rendered error pages #661

Open
jarrodldavis opened this issue May 5, 2019 · 5 comments

Comments

@jarrodldavis
Copy link
Contributor

When hydrating the client-side app from a server-side rendered error page, the segment prop provided to _layout.svelte is incorrect (for me, it's undefined).

The issue appears to be here:

const props = {
error,
status,
session,
level0: {
props: root_preloaded
},
level1: {
props: {
status,
error
},
component: ErrorComponent
},
segments: preloaded
}

which is vastly different than the normal logic used to create the props.segments array:

const segments = page.path.split('/').filter(Boolean);
let redirect: Redirect = null;
const props = { error: null, status: 200, segments: [segments[0]] };

branch = await Promise.all(route.parts.map(async (part, i) => {
props.segments[l] = segments[i + 1]; // TODO make this less confusing
if (!part) return null;

preloaded appears to be, as the name suggests, the results of invocations of preload functions, as appropriate, for components rendered server side and serialized to the client.

@t-heuser
Copy link

t-heuser commented Nov 6, 2019

Same for me in a freshly installed sapper environment.

@ajbouh
Copy link

ajbouh commented Jul 27, 2020

I've been working getting sapper to compile with TypeScript in strict mode and also came across this surprising assignment.

I haven't been able to find any documentation about what the contract for segments is, so it's been a challenge to fix it. Does anyone subscribed to this issue have any suggestions?

@pngwn
Copy link
Member

pngwn commented Jul 27, 2020

Segment might not be around for much longer: #824

@pngwn
Copy link
Member

pngwn commented Jul 27, 2020

Oh hey, it was that issue's birthday yesterday.

@lmf-git
Copy link

lmf-git commented Sep 9, 2020

Happy birthday. Getting this error on fresh install for zero reason. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants