-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
I'm working on a PWA that prerenders the root page endpoint located inside an (app) layout group (so the service worker has access to the app shell) with a fetch in (app)/+layout.ts (which is NOT prerendered) that authenticates the user and redirects to a sign-in page at run-time.
This somewhat hacky setup was producing the desired behavior until version 1.27.4 - namely a prerendered index.html app shell that attempts authentication (along with fetching various cacheable assets) only at run-time and makes related data from the parent (app) layout load function accessible to subsequent load functions inside the group.
After version 1.27.4, the build process errors out because it now seems to attempt to authenticate (and redirect) at build time:
node:internal/event_target:1033
process.nextTick(() => { throw err; });
^
Error: 404 /api/validate (fetched from /)
To suppress or handle this error, implement `handleHttpError` in https://kit.svelte.dev/docs/configuration#prerender
Reviewing the build output, the index.html is now referencing the sign-in page redirected to on failed auth attempts. If I explicitly add export const prerender = false to this endpoint, the error instead becomes
Error: /api/(auth)/validate is not prerenderable
The errors looks similar to #11031 and likewise seems related to the changes introduced here - the issue started in version 1.27.4 and downgrading to 1.27.3 fixes it. It still persists in version 1.27.6 after related issues with fully-static sites seems to have been closed.
Reproduction
Unfortunately a simple reproduction is not feasible due to the dependencies on auth etc.; hopefully the info provided + related issues are enough for a start. If I manage to narrow things down to where a reproduction is feasible I'll post an update.
Logs
No response
System Info
System:
OS: Linux 6.2 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
CPU: (32) x64 AMD Ryzen 9 5950X 16-Core Processor
Memory: 14.34 GB / 62.71 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
pnpm: 8.9.0 - ~/.nvm/versions/node/v18.18.0/bin/pnpm
npmPackages:
@sveltejs/adapter-vercel: ^3.0.3 => 3.0.3
@sveltejs/kit: ^1.27.6 => 1.27.6
svelte: ^4.2.3 => 4.2.3
vite: ^4.5.0 => 4.5.0Severity
blocking an upgrade
Additional Information
No response