Skip to content
This repository was archived by the owner on Jan 11, 2023. It is now read-only.

(Rollup v3) preload not getting called consistently on server, but always runs on client #594

Closed
arxpoetica opened this issue Mar 5, 2019 · 10 comments

Comments

@arxpoetica
Copy link
Member

arxpoetica commented Mar 5, 2019

Update it's consistent, and it has to do w/ style preprocessing.

Unfortunately, I've had a very difficult time pinning this down, but it appears that preload sometimes doesn't get called on the server. It's totally inconsistent, and I can't reproduce it on anything reliable, but it seems to be happening when I switch to different pages with different preloads (and refreshing).

Navigating to new pages that are not server hits (but client only) is just fine and works great. It's the server that sometimes doesn't call preload.

Sorry this is less helpful. I feel pretty blind as to what the problem is. It'll start working and I'll have no clue, and then the next moment it won't.

Potentially related bugs: #554, #415, #589, #586, #588, #587, and #555.

@arxpoetica arxpoetica changed the title (Rollup v3) preload not getting called inconsistently on server, but always runs on client (Rollup v3) preload not getting called consistently on server, but always runs on client Mar 5, 2019
@dxlbnl
Copy link

dxlbnl commented Mar 7, 2019

Is this with svelte.v3 & sapper alpha? I seem to be having the same issues there at least. although it is very consistently not being called on the server.

Put a sample video online.
Here's a REPL link

@arxpoetica
Copy link
Member Author

arxpoetica commented Mar 7, 2019

@neoel are you using CSS preprocessors anywhere?

@dxlbnl
Copy link

dxlbnl commented Mar 7, 2019

@arxpoetica Yeah, I am using svelte-preprocess. For loading scss styles. I've tried only passing the styles prop in the preprocess object .

// svelte opts:
{
   ...
   preprocess: { style: preprocess().style }
}

But that didn't seem to influence it.

@dxlbnl
Copy link

dxlbnl commented Mar 7, 2019

Ah, I've now completely removed it. And it does not trigger the bug. So svelte-preprocess has something to do with it then, any clue what changes cause this. (I'm not familiar with the innards here)

@arxpoetica
Copy link
Member Author

I created a repro: https://github.com/arxpoetica/gah

@Conduitry
Copy link
Member

Quick summary of findings: The has_preload function (that's used in generating the manifest that will determine whether to call preload on server renders) does not and cannot know about any preprocessors you may want to run on your code and it attempts to compile it as-is. This fails with things with e.g. invalid styles which need preprocessing, and when compilation fails Sapper assumes there's no preload in the component.

A possible solution (which would only work with <style>s that need preprocessing, which I imagine would be the majority of the cases this would show up) is to just nuke any <style> tags before has_preload sends the component to the compiler, since those aren't going to affect whether there's a preload anyway.

@arxpoetica
Copy link
Member Author

PR #597

Conduitry added a commit that referenced this issue Mar 8, 2019
strip out style blocks (#594)
@Conduitry
Copy link
Member

Closing this - should be fixed in alpha 12. 🤞

@yamiteru
Copy link

preload still doesn't get called

@arxpoetica
Copy link
Member Author

@YamiteruXYZ can you confirm Sapper and Svelte versions?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants