-
-
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
feat: Fail prerendering for pages with mutative endpoints - fixes #3410 and #4252 #4812
Conversation
🦋 Changeset detectedLatest commit: b9aca90 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Only downside of this that I can think of is that it'll only fail in dev when a server-side navigation occurs... but I don't think it's even possible to check for prerendering in the client. (A quick search of |
Thank you! There was one small change I needed to make — whereas in the page Though thinking about it, |
I renamed |
Thanks for renaming this. I knew there was something not making sense -- I thought maybe the prerender configuration was assigned to |
Ah whoops, looks like I broke something. Will look into it in a bit |
Bah, I looked into it for a bit, but I'm just not sure what's causing the issue. To save you some time, what's failing is a test in |
In case this is useful to you, my experiences: I tried to update my blog that uses adapter-static the day before yesterday and it didn't build right - only one of my *.svelte pages (incidentally the simplest and most recently edited) was built into a *.html file. I could open the site via that one rendered html page and - I'm not smart enough yet to understand how it all works - I guess the rest was populating itself via JS and it sort of worked. Apart from, the blog index page which complained about the JSON it was referencing having a rogue Anyway eventually I paid attention to some warnings I was getting in the terminal, saying I had to add Then after that it built fine again. Are these lines I will have to change back once any fixes happen? Thanks! |
Hey @sarajw! This is an unrelated issue and is actually intended behavior (unless there's something I'm not understanding about your issue). The terminal warnings you were seeing were trying to tell you this. For |
Absolutely fine if that's the case, it was just new and surprising. I had already posted in the Discord SvelteKit channel and not got much help or information. |
And to be clear, I'm not saying you're not experiencing a bug -- just that I don't see any buggy behavior described in what you said. If you still think you are, please do create a repro and file an issue. 🙂 I personally think it's kind of weird that |
thank you! |
There are a few issues up around the confusing things that happen if a page is prerendered with mutative methods. Thankfully, this already errors at buildtime. However, it can be a bit of a footgun during development, as there's no warning what you're doing isn't valid until you try to build.
Added tests to make sure that, if a page should be prerendered (both a build-time and at runtime), it fails to do so with a descriptive message.
Fixes #3410 and fixes #4252.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
Tests
pnpm test
and lint the project withpnpm lint
andpnpm check
Changesets
pnpx changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0