Skip to content
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

Unrecoverable error in <Root> #6273

Closed
zwergius opened this issue May 1, 2021 · 14 comments
Closed

Unrecoverable error in <Root> #6273

zwergius opened this issue May 1, 2021 · 14 comments

Comments

@zwergius
Copy link

zwergius commented May 1, 2021

Describe the bug
After updating to 3.38 I am seeing errors in the console, downgrading to 3.37 seems to resolve the issue

Logs
Screenshot 2021-05-01 at 09 58 02

To Reproduce
Happens in my svelteKit project on initial load

@johngrasty
Copy link

I’m seeing the same, but I haven’t been able to make a minimal reproducible example. In my one project, I see it when I use: {@html }

@johngrasty
Copy link

So with my example where {@html } is causing this error, it seems to be related to #6274. When I remove <div id="svelte">%svelte.body%</div> and set target: 'body' in svelte.config.cjs, both this error and the error from #6274.

@Conduitry
Copy link
Member

Can you try 3.38.1? That should have fixed #6274 and so may also fix this.

@kharanenka
Copy link

I still have the error with using {@html ...} in 3.38.1 version too... Bug with duplication was fixed in 3.38.1 version.

@johngrasty
Copy link

@Conduitry @kharanenka Likewise for me 3.38.1 fixed the duplication issue, but it did not fix this {@html…} error. However removing %svelte.body% and targeting the body in svelte.config.cjs resolves both. I have not been able to create a minimal working example though. In my larger project, I am using mdsvex…maybe connected, maybe not.

@kharanenka
Copy link

I try to remove <div id="svelte">...</div> and configure target to body, but i have both error on 3.38.0 version and {@html…} error on 3.38.1 version. It doesn't fix my project.

@johngrasty
Copy link

So upon further investigation, the workaround of removing %svelte:body% leads to, as one would expect, breaking of prerendering.

@johngrasty
Copy link

First, sorry that I am not more capable in debugging and fixing such things!

Second, at least in my case, I have narrowed down the problem. I am rendering an SVG with {@html }, and the error is coming from this line:

node.parentNode.removeChild(node);

Here's the function

function end_hydrating() {
    is_hydrating = false;
    for (const node of nodes_to_detach) {
        node.parentNode.removeChild(node);
    }
    nodes_to_detach.clear();
}

When I do some console logging, I see in my project a number of #text nodes and a few svg nodes. When I look at node.parentNode, it is null for the svg nodes, and that is when I am hitting this error. If I replace the {@html bunch of svg code} with just the svg code, there is no error.

Maybe this will help a bit.

@zwergius
Copy link
Author

zwergius commented May 2, 2021

Hi again

3.38.1 does not fix the issue in my case...

So based on other comments in this issue I did a bit of further digging, I also target directly, so adding back in

did not change anything in my case.

I also use {@html ...} in various places, among others in my $layout, removing this line does solve the issue.. I still use it in other places and they keep working without throwing errors..

I hope this helps narrowing it down!

Thanks

@johngrasty
Copy link

I'm still trying to reproduce this in a minimal example repo, but I did discover something in my project:

This snippet sees the error mentioned above:

<div>
     {@html item.icon}
</div>

but this works and does not get the error:

<div>
     {@html '<div />'}
     {@html item.icon}
</div>

I don't know why, but maybe it will help those working on this.

@zwergius
Copy link
Author

zwergius commented May 4, 2021

Hi again,

Spun up this reproduction repo

https://github.com/zwergius/svelte-issue-6273

** With recent svelte 3.38.2 issue does NOT exist

Hope this helps

@johngrasty
Copy link

@zwergius It's great that you were able reproduce this in a simple way! Most likely the problem does not exist in 3.38.2, because they ended up reverting the hydration changes in #6290.

@stale
Copy link

stale bot commented Oct 31, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale-bot label Oct 31, 2021
@stale
Copy link

stale bot commented Nov 14, 2021

This issue has been closed as it was previously marked as stale and saw no subsequent activity.

@stale stale bot closed this as completed Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants