You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SvelteKit v1.0.0-next.304 is suddenly executing code during build, prerender problem?Β #4492
I am building a full stack SvelteKit adapter-node application with database connection. It is build in a container to be run in a container. Todays npm update killed my build process because npm run build started to execute my source code.
So far this would build, but with SvelteKit v1.0.0-next.304 (and its dependencies) build started to fail:
// hooks.ts
export const handle = async ({ event, resolve }) => {
// simulate crash because DB can not be connected
// without credentials and access during build process
console.log('Going to simulate crash')
process.exit();
const response = await resolve(event);
return response;
};
My last goodnpm update was 3 days ago.
Note: The build process always worked, but I had to use npm ci --production --ignore-scripts later with the built code.
This may have to do with the pre-rendering, but I have not touched those settings.
Why would you pre-render when prerendering.enabled = false? #4443 makes no sense to me.
Because we still need a fallback file when using the static adapter with prerendering disabled, otherwise you don't get a usable app at all. Perhaps the fallback file generation needs to be separated from the prerender process.
If you read the second line of my comment I suggested that the fallback file generation be separated out. The way it works right now theyβre very closely intertwined for reasons that Iβm not sure of but probably just never mattered before the pretender process was moved into the build step.
Everyone lets all calm down please. Itβs not like weβre out here trying to break things for you. I wasnβt freaking out on here when my build broke due to the earlier pre-rendering change. Instead I pinned my version to a working one and helped to figure out a solution. You would be good to do the same.
Just pin your version to 303 for now and we can all get this fixed in a calm manner.
Bugs eventually squeeze in unnoticed, and being on the @next edge of a fast-changing prerelease library means you'll eventually hit them. We welcome collaboration on getting things fixed, but pointing out how obvious a bug is from your perspective doesn't help anyone.
I'm bumping this to p0-urgent, but please let's strive to keep the discussion constructiveβadding a thumbs up to the issue is enough to signal you were (unfortunately) affected by it.
Reacted by Arad Alvand, Maxime, bluepuma77, Morgane Crosnier De Bellaistre, sinbino and Quintin Henry
On Apr 10, 2022, 6:07 AM -1000, Mihael MutiΔ ***@***.***>, wrote:
@dimfeld you don't understand me, I need hooks(getSession at least, and some may even need handle hook) to run even for generating fallback file, because I need default session to bet set for everything to work
β
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
No you don't, and you don't understand how fallback is generated. I know it doesn't contain layout or page, but it DOES contain <script> tag with start function invocation, and one of the parameters of that function is session and that parameter gets filled out by getSession hook in here
Apologies, I had just woken up and wasnβt properly thinking things through. Of course the session would need to be seeded even in fallback mode.Β Β Sorry for the curt response earlier.
So at this point I think that the following changes should be sufficient:
Revert the previous PR that changed the fallback render behavior
Mention in the SPA Mode section of the adapter-static docs that setting prerender.entries: [] can help if Node.js throws errors when importing your page/layout components.
If I have some time tonight I'll try to get a PR together for this.
When setting prerender.entries: [] in config, it helps to skip the problem, but then the whole sense of adapter-static is lost, it seems... At least, upon building with prerender.entries: [], I'm not seeing all my static pages in build folder, and say... Can't use it for Github Pages.
Maybe there's actual solution, rather than skipping the problem?
P.S. I used the most currently recent "@sveltejs/kit": "1.0.0-next.405" and "@sveltejs/adapter-static": "1.0.0-next.39".
Activity
bluepuma77 commentedon Apr 1, 2022
Setting full
does not help
mrkishi commentedon Apr 1, 2022
Likely to have been introduced by #4443, since now we try creating a fallback regardless of prerender settings.
I'm not sure how we want to deal with it, though.
bluepuma77 commentedon Apr 2, 2022
aradalvand commentedon Apr 2, 2022
dimfeld commentedon Apr 3, 2022
Because we still need a fallback file when using the static adapter with prerendering disabled, otherwise you don't get a usable app at all. Perhaps the fallback file generation needs to be separated from the prerender process.
ximus commentedon Apr 3, 2022
bluepuma77 commentedon Apr 3, 2022
@dimfeld So the solution would be to only ignore
prerendering.enabled = falsewhen usingadapter-static.Because it seems wrong for all the other adapters. We could completely remove
prerendering.enabled.aradalvand commentedon Apr 3, 2022
ponderingexistence commentedon Apr 3, 2022
ponderingexistence commentedon Apr 3, 2022
By the way, I think the p0-urgent label is more appropriate for this.
It's breaking a lot of people's stuff.
aahmadi458 commentedon Apr 3, 2022
dimfeld commentedon Apr 3, 2022
If you read the second line of my comment I suggested that the fallback file generation be separated out. The way it works right now theyβre very closely intertwined for reasons that Iβm not sure of but probably just never mattered before the pretender process was moved into the build step.
Everyone lets all calm down please. Itβs not like weβre out here trying to break things for you. I wasnβt freaking out on here when my build broke due to the earlier pre-rendering change. Instead I pinned my version to a working one and helped to figure out a solution. You would be good to do the same.
Just pin your version to 303 for now and we can all get this fixed in a calm manner.
mrkishi commentedon Apr 3, 2022
Bugs eventually squeeze in unnoticed, and being on the
@nextedge of a fast-changing prerelease library means you'll eventually hit them. We welcome collaboration on getting things fixed, but pointing out how obvious a bug is from your perspective doesn't help anyone.I'm bumping this to
p0-urgent, but please let's strive to keep the discussion constructiveβadding a thumbs up to the issue is enough to signal you were (unfortunately) affected by it.13 remaining items
dimfeld commentedon Apr 10, 2022
PH4NTOMiki commentedon Apr 10, 2022
No you don't, and you don't understand how fallback is generated. I know it doesn't contain layout or page, but it DOES contain
<script>tag withstartfunction invocation, and one of the parameters of that function issessionand that parameter gets filled out bygetSessionhook in herekit/packages/kit/src/runtime/server/page/render.js
Lines 163 to 165 in 1c0b6b6
PH4NTOMiki commentedon Apr 10, 2022
For fallback its here
kit/packages/kit/src/runtime/server/index.js
Lines 179 to 184 in 32a700a
dimfeld commentedon Apr 10, 2022
PH4NTOMiki commentedon Apr 10, 2022
No worries, I reacted a bit harsh too.
dimfeld commentedon Apr 11, 2022
So at this point I think that the following changes should be sufficient:
adapter-staticdocs that settingprerender.entries: []can help if Node.js throws errors when importing your page/layout components.If I have some time tonight I'll try to get a PR together for this.
Revert sveltejs#4443: Create fallback HTML file when prerendering is β¦
skip fallback generation if prerendering is disabled - fixes #4492
Revert change to render fallback when prerendering is disabled (#4604)
ximus commentedon Apr 14, 2022
thanks @dimfeld for carrying this through
jerrygreen commentedon Aug 15, 2022
When setting
prerender.entries: []in config, it helps to skip the problem, but then the whole sense ofadapter-staticis lost, it seems... At least, upon building withprerender.entries: [], I'm not seeing all my static pages inbuildfolder, and say... Can't use it for Github Pages.Maybe there's actual solution, rather than skipping the problem?
P.S. I used the most currently recent
"@sveltejs/kit": "1.0.0-next.405"and"@sveltejs/adapter-static": "1.0.0-next.39".Rich-Harris commentedon Nov 18, 2022
hey all β flagging this discussion, as people here might have thoughts on it: #7716