-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
SvelteKit v1.0.0-next.304 is suddenly executing code during build, prerender problem? #4492
Comments
Setting full
does not help |
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. |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
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. |
This comment was marked as duplicate.
This comment was marked as duplicate.
@dimfeld So the solution would be to only ignore Because it seems wrong for all the other adapters. We could completely remove |
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
By the way, I think the p0-urgent label is more appropriate for this. |
This comment was marked as duplicate.
This comment was marked as duplicate.
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 I'm bumping this to |
Why not roll back the change? SvelteKit has many adapters, it seems only relevant for one. For |
Using I guarantee there's a way to fix this that results in working builds for everyone; let's work on that. |
Ok, I believe I found a workaround for my case. It's a little weird but appears to work. Setting With this workaround, I think we can perhaps go back to the |
Is the fallback html truly only used for SPA mode or is it used on some other condition? If it's really only used for SPAs, it does sound like we should render the fallback differently by not running a full SSR but instead just filling |
I think it's only for SPA mode but I'm not 100% sure on that. Your suggested solution is basically what I was thinking too, since it doesn't appear to be doing anything that actually needs to start the The current behavior is to take the Looking at the output on my project at work, I see these replacements:
<meta http-equiv="content-security-policy" content="">
<link rel="modulepreload" href="/_app/start-75b9d96b.js">
<link rel="modulepreload" href="/_app/chunks/index-7a365041.js">
<link rel="modulepreload" href="/_app/chunks/index-d3785d77.js">
<link rel="modulepreload" href="/_app/chunks/preload-helper-e4860ae8.js">
<link rel="modulepreload" href="/_app/chunks/singletons-d1fb5791.js"> And then <script type="module" data-hydrate="45h">
import { start } from "/_app/start-75b9d96b.js";
start({
target: document.querySelector('[data-hydrate="45h"]').parentNode,
paths: {"base":"","assets":""},
session: {},
route: true,
spa: true,
trailing_slash: "never",
hydrate: null
});
</script> |
FWIW, I ran into this today as well but I'm using the node adaptor. I don't have any prerenderable routes, (I've never set the The code I have in hooks.ts is pretty simple. I simply look for a required server env var and throw an exception if it's not available. const envKey = process.env.ENV_KEY
if(!envKey) {
throw new Error('missing ENV_KEY')
} I do this in order to fast-fail the server startup. The reason I'm writing all of this is because there's probably a better hook for this code, e.g. something like this in hooks.ts: export const onStartup = async (...) => {
// my code
}; Anything like this on the radar? It would solve this code execution during build problem for this use-case. Thanks! |
@Rich-Harris @benmccann We have a real blocker here for many Sure, you can argue that we can just sit on the last working version, but that means we are also staying with the other bugs that have been fixed in the mean time with later releases. If this is "just" for |
I had an idea in dimfeld@5d1beb1 to try to run the fallback generation without loading hooks but haven't had the time to really try it yet. |
@dimfeld that is not really a viable option(running without hooks), because i'm using adapter-static and I have default session set similar to this: The best solution(temporary) is to somehow emulate the behavior in your work-around(empty |
Please look at the change itself; that is not what’s happening. It renders only the fallback without hooks, not the entire app.
Anyway I haven’t been able it try it out yet to see if it actually works. If anyone else would like to, please feel free
…On Apr 10, 2022, 5:07 AM -1000, Mihael Mutić ***@***.***>, wrote:
@dimfeld that is not really a viable option(running without hooks), because i'm using adapter-static and I have default session set similar to this: {user:{id:null, firstName:null}} and in Svelte components I use something like this: {#if $session.user.id != null} and that would break if you did that, because the getSession wouln't run and session would be {} and that wouldn't work.
And I'm also sure there are other cases when running handle hook is necessary(even for adapter-static), and that would break too.
The best solution(temporary) is to somehow emulate the behavior in your work-around(empty entries)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@dimfeld you don't understand me, I need hooks( |
I do understand you. I don’t think you understand how the fallback file is generated. It doesn’t load any pages or layouts.
…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 kit/packages/kit/src/runtime/server/page/render.js Lines 163 to 165 in 1c0b6b6
|
For fallback its here kit/packages/kit/src/runtime/server/index.js Lines 179 to 184 in 32a700a
|
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.
…On Apr 10, 2022, 6:30 AM -1000, Mihael Mutić ***@***.***>, wrote:
For fallback its here https://github.com/sveltejs/kit/blob/32a700a204e108a1fdceeffc7727bdb340335a3e/packages/kit/src/runtime/server/index.js#L179-L184
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
No worries, I reacted a bit harsh too. |
So at this point I think that the following changes should be sufficient:
If I have some time tonight I'll try to get a PR together for this. |
* Revert #4443: Create fallback HTML file when prerendering is disabled Fixes #4492 * Document `config.kit.prerender.entries: []` workaround for SPA mode * add test * tweak changeset * lockfile * Update packages/adapter-static/README.md Co-authored-by: Rich Harris <[email protected]>
thanks @dimfeld for carrying this through |
When setting Maybe there's actual solution, rather than skipping the problem? P.S. I used the most currently recent |
hey all — flagging this discussion, as people here might have thoughts on it: #7716 |
Describe the bug
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 becausenpm 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:My last good
npm 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.
Reproduction
https://stackblitz.com/edit/sveltejs-kit-template-default-9crzvj?file=src%2Fhooks.js
Run
npm run build
and it will execute the code and exit the processLogs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: