-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
prevent dynamic components being detached twice #3172
Conversation
I can confirm that this fixes #2086 tested using: |
Can also confirm this fixes #2086. |
When using this branch locally with Sapper and the default sapper-template, navigating between pages is now causing the new page to be appended to the old one. |
This PR does not address the I also added some reasons in #3156 why we should have the I've essentially been saying the same thing in several issues. Should we consolidate all discussion on the Here are some of the other related issues & pull requests that I could find from a cursory search. #2086 |
Two other people were unable to reproduce the issue with Sapper I mentioned above, and when I tried again just now I wasn't able to either. I'm withdrawing that concern. It's be nice to know what was happening there for me before, but oh well. This does also seem to address the issue when navigating away from a page with a I'm also copying my comment on #3156 over here so it's more visible, as this seems to be the main place where stuff related to this is going to happen.
@pngwn said:
|
I missed this. In the spirit of consolidating our discussion, I'll repost the response I made:
|
@Conduitry I can reproduce the error you showed above. I am getting this when using "btakita/svelte#gh-3113-hotfix". It's definitely an issue. First link I clicked failed in fact. This is definitely not ready to merge yet. |
Here's a video of the issue, caused by the proposed fix, that I've screenshotted above. |
In case it's useful - here's the site with the latest Svelte release 3.6.5 - the site is unnavigable - no links on the entire site work, just throw errors. |
In case it is useful - the page append happens far more frequently in full-screen browser on large monitors, and on a mobile phone. it seems to be about 50% of the time when you hit back, the page will append the new page to the bottom of the old one, and the whole site will just break. This also occurs on Svelte 3.5.4. |
What's the easiest way to reproduce that failure while using this branch? |
@Rich-Harris which failure are we looking at? they've all gotten a bit conflated. The easiest way to replicate the detach failure - I believe, is to add some svelte:head meta tags to your pages. You can see what that does on my QA site: https://qa.beyonk.com/uk - not a single page/link works - I am trying to make a very small repro of this but I'm blocked by other issues in doing so at the moment. In terms of the page-appended-to-page issue - this exists in 3.5.4 and possibly earlier too, but with a much less severity - I think therefore it's not entirely related, but it's also hard to reliably reproduce - I have discovered that my site suffers most because I a paginate when an intersectionobserver is hit in my footer. The way this then causes pages to be appended is as follows:
I think I can recreate the second by a repro adding content to the page on a timer. I'm also working on this. |
Re the argument in favour of consolidating the check — I definitely see the appeal, but there is a performance difference — in a test I ran just now, detaching many nodes from a parent, doing it without a check went 20% faster in Firefox than with the check. In Chrome it was 8%. But my larger concern, echoing @Conduitry, is about masking bugs. I really would prefer to get to the underlying problem rather than working around it. In Svelte's early days, it would detach every node from its parent during component destruction (rather than just the top-level node), and it was catastrophic for performance — that's the kind of thing that can easily creep back in if we start writing code defensively rather than correctly. |
@Rich-Harris Is there much performance difference between a check and a try/catch? |
@half-cambodian-hacker-man looks like in Chrome, try-catch is on a par with no check. In Firefox, there's a significant try-catch penalty |
@Rich-Harris here's the simplest possible reproduction of the detach issue: https://github.com/beyonk-adventures/svelte-detach-issue Basically just the sapper template with a meta tag added to head - hope this is what you meant. Working on the append issue now. |
I can't run that previous repro against this branch because I get the following issue when trying to
|
@antony I've merged master into this branch, and navigating away from the index page works in your repro with this branch linked. I've got half a mind to merge this branch and cut a release, and deal with any additional bugs thereafter. Might be easier to isolate things that way. |
@Rich-Harris I'm inclined to agree |
that fixed the meta tag issue inside head sveltejs/sapper-template#158 |
fixes #3113. I suspect this is also the correct fix for #2086