Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty client layout load #542

Merged
merged 13 commits into from
Sep 15, 2022
Merged

Empty client layout load #542

merged 13 commits into from
Sep 15, 2022

Conversation

AlecAivazis
Copy link
Collaborator

@AlecAivazis AlecAivazis commented Sep 13, 2022

Fixes #541

After working with @endigma, it turns out that the culprit for this issue was a rather innocent looking load function in a +layout.ts file:

export async function load() {
    return {}
}

I poked around this for awhile but everything I found seemed to indicate that only relying on +layout.server.ts meant that if a load function returns an empty object, we lost the session data. So now, the vite plugin adds a load to the root layout that passes the server's value down to children (who can pick it up from event.data before they have to await parent().

This honestly was a lot of stabbing in the dark since it my expectations were clearly not matching kit's behavior. If @fehnomenal has some time to look at this, I would be super appreciative.

To help everyone out, please make sure your PR does the following:

  • Update the first line to point to the ticket that this PR fixes
  • Add a message that clearly describes the fix
  • If applicable, add a test that would fail without this fix
  • Make sure the unit and integration tests pass locally with pnpm run tests and cd integration && pnpm run tests
  • Includes a changeset if your fix affects the user with pnpm changeset

@AlecAivazis AlecAivazis linked an issue Sep 13, 2022 that may be closed by this pull request
@changeset-bot
Copy link

changeset-bot bot commented Sep 13, 2022

🦋 Changeset detected

Latest commit: dea5842

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Sep 13, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
docs ✅ Ready (Inspect) Visit Preview Sep 14, 2022 at 8:29PM (UTC)
docs-next ✅ Ready (Inspect) Visit Preview Sep 14, 2022 at 8:29PM (UTC)

@fehnomenal
Copy link
Contributor

Ah yes, I remember reading about that in a kit issue but cannot find it anymore, or was it a discussion 🤔

Regardless the gist was that you explicitly have to return event.data from +layout.ts/+page.ts loads.

src/vite/transforms/kit/load.ts Outdated Show resolved Hide resolved
src/vite/fsPatch.ts Outdated Show resolved Hide resolved
src/runtime/lib/network.ts Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Loading in layouts broken?
3 participants