Skip to content

Page with +page.server.ts but SSR disabled breaks site (__data.json not found, infinite redirection loop) #6243

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

Closed
aloker opened this issue Aug 24, 2022 · 1 comment · Fixed by #6251

Comments

@aloker
Copy link
Contributor

aloker commented Aug 24, 2022

Describe the bug

The following scenario:

  • A route with +page.svelte and +page.server.ts
  • SSR disabled for said route via hooks.ts

During dev this works fine:
No matter whether the route is invoked directly or visited through client side routing, the loads its __data.json and renders fine (if called directly, no server side rendering takes place as expected)

However, in production mode (tested with Vercel, node and Azure SWA) visiting the route causes an infinite redirection loop in the browser. The request for __data.json causes a 404.

The same behavior occurs when there's a +layout.server.ts involved.

Reproduction

Example repo: https://github.com./aloker/kit-non-ssr-data-issue
The main branch uses adapter-auto, the adapter-node branch uses adapter-node

Notice that this runs fine in dev-mode and when running tests.

Vercel-deployment: https://kit-non-ssr-data-issue.vercel.app/

Node deployment: check out adapter-node branch, build project and run node build. Visiting http://localhost:3000 exposes the issue.

Logs

No response

System Info

System:
    OS: Linux 5.19 Pop!_OS 22.04 LTS
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 11.47 GB / 31.27 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 16.13.1 - ~/.nvm/versions/node/v16.13.1/bin/node
    npm: 8.12.2 - ~/.nvm/versions/node/v16.13.1/bin/npm
  Browsers:
    Brave Browser: 104.1.42.97
    Chrome: 104.0.5112.79
    Firefox: 103.0
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.66 
    @sveltejs/adapter-node: 1.0.0-next.87 => 1.0.0-next.87 
    @sveltejs/kit: next => 1.0.0-next.435 
    svelte: ^3.44.0 => 3.49.0 
    vite: ^3.0.4 => 3.0.9

Severity

blocking an upgrade

Additional Information

No response

Rich-Harris added a commit that referenced this issue Aug 25, 2022
* only generate non-SSR pages when prerendering - fixes #6243

* add explanatory comment
@aloker
Copy link
Contributor Author

aloker commented Aug 25, 2022

Thanks for the quick fix - upgrading to next.437 fixes the issue: https://kit-non-ssr-data-issue-git-upgrade-kit-aloker.vercel.app

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 a pull request may close this issue.

1 participant