-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Build process fails after attempting to prerender auth endpoints #11083
Comments
I ran into as well, but I use |
Hi, thank you both for reporting this issue. I want to apologise for causing this change that has affected your development. I tried reproducing the issue based on both your descriptions and what I think could be the cause but was not successful. It will be very helpful if you can share the full build logs from the moment of running Here is the SPA reproduction that I created to try to reproduce the issue.
It's worth noting that with prerender set to |
Hello there @eltigerchino ! I appreciate your answer. For If you downgrade to |
Thanks a ton for taking the time to setup the repo @eltigerchino, really appreciate it (and you managed to do a better job of simplifying the setup than I could)! I had a look and it seems like the build process does not prerender anything ( By replacing |
Also here another fork (restructured slightly to resemble my project) which successfully prerenders the |
The redirects are technically the correct outcome here. Since the Incidentally, the behaviour that your app is trying to produce (the same SPA setup for every HTML file) is exactly what was meant to be fixed. When |
For us the Therefore the problem is, we are lost the ability to evaluate (eg a cookie) on let's say |
The In the example below, I'm specifying the |
This is the expected result of prerendering your pages. In your case, setting it to |
I see. Also we have pages where we need to parse and use searchParams to load the page correctly. |
If you disable prerendering, it won't be a raw redirect. All requests should hit the |
This makes sense to me - and the initial setup did not (since I would expect some conflict resolution when In your new example, it does prerender the What would be the "correct" way to replicate this behavior post-1.27.3? |
From the documentation: "Child layouts and pages override values set in parent layouts, so — for example — you can enable prerendering for your entire app then disable it for pages that need to be dynamically rendered." https://kit.svelte.dev/docs/page-options
That's the expected response because it's what's returned from
The previous behaviour in 1.27.3 is a bug where the load function is not being run when prerendered. The load function should always run during prerendering.
The correct way to render an SPA app shell is to turn off prerendering and use the |
I cannot use |
I’m wondering if the old behaviour should be reimplemented as another prerender option such as |
Let me check please. (Today evening) |
Just wondering if the issue is still on the radar or if there's anything I can do from my side to help? Unfortunately not that familiar with SvelteKit internals, but I'm a bit worried about potentially being stuck on 1.27.3 indefintely, since I haven't managed to find another way to prerender the |
Sorry for the late answer.. but things happened.. work, life etc.. |
@austerj @gyurielf I've submitted a fix that restores the previous behaviour prerendering a shell page when SSR is turned off and there is no server load function for that page. This avoids running load functions during prerendering if there are no server loads we need to prerender the __data.json file for. Let me know what you guys think! |
Just had a chance to test out your fix @eltigerchino and can confirm that it solves the issue and my project is building again on the new version, thank you so much! Also really appreciate adding the test so I can sleep at night without worrying about this in the future. @gyurielf In case you want to check if the fix works for you too, I had some issues in getting
I also had to fix my import of |
I'll test it and get back. |
this is now released https://github.com/sveltejs/kit/releases/tag/%40sveltejs%2Fkit%402.0.5 |
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 afetch
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:
Reviewing the build output, the
index.html
is now referencing the sign-in page redirected to on failed auth attempts. If I explicitly addexport const prerender = false
to this endpoint, the error instead becomesThe 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
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: