-
-
Notifications
You must be signed in to change notification settings - Fork 428
Duplicated Elements in Production Build #1725
Comments
I have been troubleshooting, and it has something to do with the SVG elements. If they are removed from the app, the problem goes away. |
Here is minimal repro: https://github.com/MTyson/sapper-bug |
Where would one start debugging this? I can start digging in the code. I guess when sveltekit comes out this will be obviated... |
It only happens on chrome base browser.. I`m not having this issue on firefox, but in chrome, all mess up. |
I'm not sure what you're doing here, but I can't reproduce your issue, using chrome, or otherwise. What I did notice on refresh is some severe layout shift, as if you're not fully understanding how SSR works, and are doing a lot of your work in the client side. It appears that all of your content renders, and then some css or js hides it all so that only the view you're looking at is shown. It's possible that something in your javascript is breaking the client-side and that's why you're getting a double render. If you can follow the issue template and fill in the required sections as requested it will be easier to help you. |
I stayed the hole night trying to figure out if it was something wrong with my code, but happens that if I remove the images from Nav component, and place any other thing, the problem is finished. As soon as i put 2 different images, every thing rips apart. It gets easy be replicated with sapper template, and add 2 or 3 different images to Nav.svelte. This bug happens on chrome and firefox just check below. You can test here for a while: After some chat, i think that sapper interpreter are trying to find < / img ">, but images doesnt finish like that, or we get an error, imgs finish />... so sapper bugs trying to find this tag that doesnt ecxists in html. |
^ I do not know that it's the image tag. I have seen the bug, and it's weird and inconsistent. |
There's so much going on with that site that I don't know where to begin. I loaded it the first time in a fresh browser and I got a navigation bar with pink icons. Then when I loaded it again a couple of times I got a different site needless to say the error isn't recreatable any more, since the site with the issue seems to have disappeared. I'm afraid there seems to be a need for more work to isolate and reliably reproduce this issue - it's a bit of a moving target at the moment. You might remove the service worker to reduce the complexity of the app. |
Sorry, i was testing other versions of sapper to see if it was without this problem, but my vps crashed and i have to rebuild it, in the meanwhile i got out of light in my building. I'll re-build the server again and warn you about it. But it is simple, where is writen on sapper template, Home, About, Blog, between "a" tag, change it, placing 3 different images, and you get the bug. Anyway.. |
The way to create a repro for this is: Get the buggy repro locally, make it as small as humanly possible so that the bug is really isolated, and run Beyond that, there are way too many things going on here to try to fix the issue. |
Done it! |
I am also seeing this in production. As for how to reproduce with @bardobrado's repo, the following may help:
Also, by |
To create that later example, all I did was take the standard template and put a couple SVG in the navbar. We basically put production on hold and are awaiting sveltekit hoping that will fix this. Thanks for taking a look @antony |
I'm just glad we aren't the only team experiencing this. A real nightmare. I was able to repro the bug on your site, @bardobrado |
We tried rolling back to earlier versions of Sapper/Svelte (and related plugins), but it still repro'd the bug. |
Which version(s) of Sapper did you go back to? |
I don't recall exactly all the versions, but we are on sapper 0.29.1 right now, and we went back to 0.28.x for sure. I'm pretty sure we tried 0.27.x also. (We also changed svelte and the other related deps). |
|
one month ago , that not happen. |
FYI: Not that this issue shouldn't be fixed on the sapper side of things, but I couldn't reproduce this issue with svelte-kit. |
Thank god. |
Same server: you can try 3001 port, refresh page and will see the bug! but if you visit cms.beefun.cc, refresh page and work fine! @MTyson i can provide my test server if you want and my code is open source, so dont worry. |
Hi, just got same problem upgrading from 0.27.x to 0.29.x. I have a login page with just a button and if I reload the page I got two buttons, side by side. In the svelte page I have a simple Login tag. |
Right, so it makes sense why I'm not seeing this now. I took a fork at Sapper 0.27.* and have been running off this. It looks like this was introduced somewhere after 0.28. My advice is, if you've upgraded to Sapper 0.28 or later, I would revert that upgrade. We would also welcome help from the community in diagnosing and fixing this issue, since our resources to do so are very limited right now. If a fix is made for this issue we will create a new release to publish it, despite Sapper being in maintenance mode. |
@antony - where would you start in debugging this? |
I think I have found the solution.
The reason why 0.28.0+ was because sveltejs/sapper-template@d4c75af#diff-4b1d306eb7949b768a10a68600e5973cdcbeafa0827e6f6e3c78c55269d4cc0b . I believe this causes the sapper script to be evaluated before the DOM has actually been properly mounted on slower connections, thereby creating duplicate elements. This becomes more pronounced the larger the client script is (i.e. base64ed images). It's the best explanation I've got anyways. |
Bad ass!! |
It is also worth repeating in this thread that a more elegant solution, suggested by @benmccann, is wrapping your sapper.start() in a window load event listener. // src/client.js
window.addEventListener('load', () => sapper.start({
target: document.querySelector('#sapper')
})); |
Hi, I can confirm @babeard solution is working, no more duplicated content. |
Likewise, using the load event in client.js fixed the problem. |
Could people test if #1722 fixes this? |
Unfortunately, no. I tested that a week ago and again just now and no dice. According to MDN
|
I just saw a variation of this bug after not seeing it for a while (after using this fix: #1725 (comment)) Seems to be mostly fixed though. |
Hmm. @MTyson did you use the window load event method or the append |
I used the |
Hi, Just want to add to this that adding |
We recently had the duplication with components with SVGs. Strangely, it was caused by the hydration because the original page source didn't contain any duplication. We found that there was a |
Thanks @asdfdelta , that is a good find. |
In my case, when I used saper with ssr, it ignored first element inside |
I have markup like so:
In my nav.svelte component. This works fine in dev.
However, in production, there is often a strange duplication of many elements. This is not consistent, but common. It is worse on remote cloud deployment of the app, but also seen on local running of prod build.
Other elements are strangely reproduced, but this is an easy instance you can see. Notice the word "referendum: is displayed twice, but only in the markup once.
The app is live here, you might need to reload a couple times to see it.
http://35.223.159.8/
The text was updated successfully, but these errors were encountered: