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

Suspense: DOMException: Failed to execute 'insertBefore' on 'Node' #3105

Closed
1 task
lxsmnsyc opened this issue Apr 6, 2021 · 9 comments
Closed
1 task

Suspense: DOMException: Failed to execute 'insertBefore' on 'Node' #3105

lxsmnsyc opened this issue Apr 6, 2021 · 9 comments

Comments

@lxsmnsyc
Copy link

lxsmnsyc commented Apr 6, 2021

  • Check if updating to the latest Preact version resolves the issue

Describe the bug
If there are multiple components that suspended at the same time and tried to resolve at the same time, there's a chance that only one of the components will successfully re-render while the rest stays in their fallback state. I'm not sure the specificity but I think one of the reasons is that Preact fails to match the component vdom to the actual dom node.

Once it fails to resolve, it throws this error:
image

This may also happen if one of the components, that isn't suspending, updates during the resolution timeframe.

A softfix for this is to wrap Suspending components with a container like a simple <div>.

To Reproduce

Steps to reproduce the behavior:

  1. Go to https://codesandbox.io/s/github/LXSMNSYC/preact-suspense-poc
  2. Click on Reload button rapidly.
  3. Check Console for error message.

Expected behavior

Should've been able to continuously retain the same behavior prior to the error.

@benjamincombes
Copy link

I have the same problem, just tried Preact for the first time, and I get this error anytime I start my app... Unfortunately, the softfix does not work for me, so I just can't use Preact until it's fixed.

@JoviDeCroock
Copy link
Member

This issue seems fixed with Preact 10.8.2 https://codesandbox.io/s/misty-cloud-u5et4t, closing for now but feel free to reopen if the issue persists for you.

@Brisstor
Copy link

Hey there! The issue appeared with Preact 10.11.2

@peacepostman
Copy link

peacepostman commented Jan 24, 2023

Hello ! I'm still having this problem with 10.11.3

If it can help, I was playing with each release and it seems that everything is working fine with the 10.9.0, every above version are randomly giving this error.

So technically something related with the 10.10.0 can be causing this random issue

@alfredsgenkins
Copy link

As a possible fix to already compiled bundle, the following can be used:

webpackConfig.module.rules.push({
    test: new RegExp('preact/compat'),
    loader: require.resolve('./preact-patch'),
});

And the loader contents:

module.exports = function patchPreact(rawSource) {
    const originalCode = `t.__e&&r.insertBefore(t.__e,t.__d)`;
    const newCode = `t.__e&&r&&r.insertBefore(t.__e,t.__d)`;
    return rawSource.replace(originalCode, newCode);
};

But indeed, why is not the originalParent checked? #3149

@BennyAlex
Copy link

Hello, I am also getting this error, is there a fix or can we reopen this issue?

@SaiHarsha-Sahukari
Copy link

Hi, Seems the issue occures in the latest version aswell. can anyone share the solution/fix for this.

@midoh7
Copy link

midoh7 commented May 11, 2023

Hi, I'm having the same error from the latest version, whats the way forward please?

@SchlagerKhan
Copy link

A softfix for this is to wrap Suspending components with a container like a simple <div>.


This solved it for my particular case :)

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

No branches or pull requests

10 participants