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

Application Error: failed to execute insertBefore on Node #9242

Open
dhavalveera opened this issue Apr 16, 2024 · 19 comments
Open

Application Error: failed to execute insertBefore on Node #9242

dhavalveera opened this issue Apr 16, 2024 · 19 comments

Comments

@dhavalveera
Copy link

dhavalveera commented Apr 16, 2024

Reproduction

{
  "name": "urband-nest-interiors",
  "private": true,
  "sideEffects": false,
  "type": "module",
  "scripts": {
    "build": "remix vite:build",
    "dev": "remix vite:dev",
    "lint": "eslint --ignore-path .gitignore --cache --cache-location ./node_modules/.cache/eslint .",
    "start": "remix-serve ./build/server/index.js",
    "typecheck": "tsc",
    "tailwind:build": "npx tailwindcss -i ./app/styles/tailwind.css -o ./app/styles/output.css --minify",
    "upgrade": "npm update",
    "check-outdated": "npm outdated"
  },
  "dependencies": {
    "@remix-run/node": "^2.8.1",
    "@remix-run/react": "^2.8.1",
    "@remix-run/serve": "^2.8.1",
    "flowbite-react": "^0.8.0",
    "isbot": "^4.1.0",
    "preline": "^2.1.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-icons": "^5.0.1",
    "swiper": "^11.1.1",
    "tailwind-merge": "^2.2.2"
  },
  "devDependencies": {
    "@remix-run/dev": "^2.8.1",
    "@tailwindcss/aspect-ratio": "^0.4.2",
    "@types/react": "^18.2.20",
    "@types/react-dom": "^18.2.7",
    "@typescript-eslint/eslint-plugin": "^6.7.4",
    "@typescript-eslint/parser": "^6.7.4",
    "autoprefixer": "^10.4.19",
    "cssnano": "^6.1.2",
    "eslint": "^8.38.0",
    "eslint-import-resolver-typescript": "^3.6.1",
    "eslint-plugin-import": "^2.28.1",
    "eslint-plugin-jsx-a11y": "^6.7.1",
    "eslint-plugin-react": "^7.33.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "prettier": "^3.2.5",
    "prettier-plugin-tailwindcss": "^0.5.13",
    "remix-development-tools": "^4.1.4",
    "tailwindcss": "^3.4.3",
    "typescript": "^5.1.6",
    "vite": "^5.1.0",
    "vite-tsconfig-paths": "^4.2.1"
  },
  "engines": {
    "node": ">=18.0.0"
  }
}

this is my package.json

import { vitePlugin as remix } from "@remix-run/dev";
import { installGlobals } from "@remix-run/node";
import { defineConfig } from "vite";
import tsconfigPaths from "vite-tsconfig-paths";
import { remixDevTools } from 'remix-development-tools'


installGlobals();

export default defineConfig({
  plugins: [remixDevTools(), remix(), tsconfigPaths()],
});

this is my vite.config.ts

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i5-1155G7 @ 2.50GHz
    Memory: 4.93 GB / 15.76 GB
  Binaries:
    Node: 20.10.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD
    bun: 1.1.0 - ~\.bun\bin\bun.EXE
  Browsers:
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.22621.1

Used Package Manager

npm

Expected Behavior

no error of insertBefore on Node error should occur

Actual Behavior

Error: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
    at insertBefore (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=1446c00d:8457:26)
    at insertOrAppendPlacementNode (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=1446c00d:17426:15)
    at commitPlacement (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=1446c00d:17382:15)
    at commitReconciliationEffects (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=1446c00d:17902:15)
    at commitMutationEffectsOnFiber (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=1446c00d:17734:15)
    at recursivelyTraverseMutationEffects (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=1446c00d:17681:15)
    at commitMutationEffectsOnFiber (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=1446c00d:17695:15)
    at recursivelyTraverseMutationEffects (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=1446c00d:17681:15)
    at commitMutationEffectsOnFiber (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=1446c00d:17733:15)
    at recursivelyTraverseMutationEffects (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=1446c00d:17681:15)

and below is my root.tsx:

import type { LinksFunction } from '@remix-run/node'
import { Links, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react'

// Stylesheet
import tailwindCss from '~/styles/tailwind.css?url'

// Layout
import CustomLayout from './layout'

// Preline Init
import { PrelineInitScript } from './components/custom-scripts'

// Constants
import { APP_NAME } from './constants'

export const links: LinksFunction = () => {
return [{ rel: 'stylesheet', href: tailwindCss }]
}

export default function App() {
return (



    <meta httpEquiv="X-UA-Compatible" content="IE=edge" />

    {/* Meta Tags */}
    <meta name="application-name" content={APP_NAME} />
    <meta name="author" content={APP_NAME} />
    <meta name="robots" content="index, follow, indexifembedded" />
    <meta name="rating" content="general" />
    {/* <link rel="canonical" href={process.env.SHARE_URL} /> */}
    <meta httpEquiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="language" content="English" />
    <meta name="creationdate" content="09-April-2024" />
    <meta name="distribution" content="global" />

    {/* GeoTag */}
    <meta name="geo.region" content="IN-GJ" />
    <meta name="geo.placename" content="Mumbai" />
    <meta name="geo.position" content="19.0760;72.8777" />
    <meta name="ICBM" content="19.0760, 72.8777" />

    {/* Some Extra Tags */}
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="default" />
    <meta name="apple-mobile-web-app-title" content={APP_NAME} />
    <meta name="format-detection" content="telephone=no" />
    <meta name="mobile-web-app-capable" content="yes" />
    <meta name="theme-color" content="#ede4d9" />
    {/* <link rel="manifest" href="/manifest.json" /> */}
    {/* <link rel="apple-touch-icon" href="/PNGLogo/favicon-16x16.png" /> */}

    <Meta />

    <Links />
  </head>
  <body>
    <CustomLayout>
      <Outlet />

      <ScrollRestoration />

      <Scripts />

      <PrelineInitScript />
    </CustomLayout>
  </body>
</html>

)
}

@brophdawg11
Copy link
Contributor

Would you mind putting together a small stackblitz via https://remix.new to demonstrate the issue?

@brophdawg11 brophdawg11 added needs-response We need a response from the original author about this issue/PR renderer:react hydration labels Apr 16, 2024
@dhavalveera
Copy link
Author

Would you mind putting together a small stackblitz via https://remix.new to demonstrate the issue?

I would like to, but my Remix App, have too many codes, and I don't know how to put everything there on stackblitz.

@github-actions github-actions bot removed the needs-response We need a response from the original author about this issue/PR label Apr 17, 2024
@brophdawg11
Copy link
Contributor

How are we supposed to reproduce and triage your issue if we don't know how it's setup?

Usually when folks begin to remove aspects one by one in order to get down to a simplified reproduction - they end up identifying the problem on their own. I would suggest doing that locally - identify a singular route that exhibits the problem, and then begin removing aspects (components, styles, etc.). Eventually you'll either see the problem disappear and know that the last thing you removed was the problem - or you'll end up with nothing left to remove and that can be used as your minimal reproduction.

@brophdawg11 brophdawg11 added the needs-response We need a response from the original author about this issue/PR label Apr 17, 2024
@dhavalveera
Copy link
Author

How are we supposed to reproduce and triage your issue if we don't know how it's setup?

Usually when folks begin to remove aspects one by one in order to get down to a simplified reproduction - they end up identifying the problem on their own. I would suggest doing that locally - identify a singular route that exhibits the problem, and then begin removing aspects (components, styles, etc.). Eventually you'll either see the problem disappear and know that the last thing you removed was the problem - or you'll end up with nothing left to remove and that can be used as your minimal reproduction.

https://codesandbox.io/p/github/dhavalveerarediff/temp/main?workspaceId=6201ff50-8b59-429f-a452-f88727602117&import=true&layout=%257B%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522rootPanelGroup%2522%253A%257B%2522direction%2522%253A%2522horizontal%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522id%2522%253A%2522ROOT_LAYOUT%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522UNKNOWN%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522clv4lw5z700062a69l7nvz534%2522%252C%2522sizes%2522%253A%255B60%252C40%255D%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522EDITOR%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522EDITOR%2522%252C%2522id%2522%253A%2522clv4lw5z700022a69yofxsao3%2522%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522direction%2522%253A%2522horizontal%2522%252C%2522id%2522%253A%2522SHELLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522SHELLS%2522%252C%2522id%2522%253A%2522clv4lw5z700042a69j981l2n4%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%257D%252C%257B%2522type%2522%253A%2522PANEL_GROUP%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522direction%2522%253A%2522vertical%2522%252C%2522id%2522%253A%2522DEVTOOLS%2522%252C%2522panels%2522%253A%255B%257B%2522type%2522%253A%2522PANEL%2522%252C%2522contentType%2522%253A%2522DEVTOOLS%2522%252C%2522id%2522%253A%2522clv4lw5z700052a69619z3p6i%2522%257D%255D%252C%2522sizes%2522%253A%255B100%255D%257D%255D%252C%2522sizes%2522%253A%255B50%252C50%255D%257D%252C%2522tabbedPanels%2522%253A%257B%2522clv4lw5z700022a69yofxsao3%2522%253A%257B%2522id%2522%253A%2522clv4lw5z700022a69yofxsao3%2522%252C%2522activeTabId%2522%253A%2522clv4mcefi00ec2a69wldrnhkq%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clv4lw5z700012a69tnbmonx8%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252FREADME.md%2522%257D%252C%257B%2522type%2522%253A%2522FILE%2522%252C%2522filepath%2522%253A%2522%252F.codesandbox%252Ftasks.json%2522%252C%2522id%2522%253A%2522clv4mcefi00ec2a69wldrnhkq%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%252C%2522clv4lw5z700052a69619z3p6i%2522%253A%257B%2522id%2522%253A%2522clv4lw5z700052a69619z3p6i%2522%252C%2522activeTabId%2522%253A%2522clv4m9vln00d82a69ia4mqg6v%2522%252C%2522tabs%2522%253A%255B%257B%2522type%2522%253A%2522TASK_PORT%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522port%2522%253A5173%252C%2522id%2522%253A%2522clv4m9vln00d82a69ia4mqg6v%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522path%2522%253A%2522%2522%257D%255D%257D%252C%2522clv4lw5z700042a69j981l2n4%2522%253A%257B%2522id%2522%253A%2522clv4lw5z700042a69j981l2n4%2522%252C%2522activeTabId%2522%253A%2522clv4m9rxl00b42a69emyz65ev%2522%252C%2522tabs%2522%253A%255B%257B%2522id%2522%253A%2522clv4lw5z700032a692956j5x5%2522%252C%2522mode%2522%253A%2522permanent%2522%252C%2522type%2522%253A%2522TERMINAL%2522%252C%2522shellId%2522%253A%2522clv4lw955007ndlgzg5i02gvp%2522%257D%252C%257B%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522CSB_RUN_OUTSIDE_CONTAINER%253D1%2520devcontainer%2520templates%2520apply%2520--template-id%2520%255C%2522ghcr.io%252Fdevcontainers%252Ftemplates%252Ftypescript-node%255C%2522%2520--template-args%2520%27%257B%257D%27%2520--features%2520%27%255B%255D%27%2522%252C%2522id%2522%253A%2522clv4m900q003o2a69he7h599c%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%252C%257B%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522dev%2522%252C%2522id%2522%253A%2522clv4m9rxl00b42a69emyz65ev%2522%252C%2522mode%2522%253A%2522permanent%2522%257D%255D%257D%257D%252C%2522showDevtools%2522%253Atrue%252C%2522showShells%2522%253Atrue%252C%2522showSidebar%2522%253Atrue%252C%2522sidebarPanelSize%2522%253A15%257D

@github-actions github-actions bot removed the needs-response We need a response from the original author about this issue/PR label Apr 18, 2024
@brophdawg11
Copy link
Contributor

That URL does not load for me?

Screenshot 2024-04-18 at 10 24 43 AM

@brophdawg11 brophdawg11 added the needs-response We need a response from the original author about this issue/PR label Apr 18, 2024
@dhavalveera
Copy link
Author

That URL does not load for me?

Screenshot 2024-04-18 at 10 24 43 AM

Sorry for the problem in previous link

please try this

@github-actions github-actions bot removed the needs-response We need a response from the original author about this issue/PR label Apr 19, 2024
@brophdawg11
Copy link
Contributor

That doesn't run for me either unfortunately:

Screenshot 2024-04-19 at 10 00 54 AM

It looks like that's just pulling from a cloned github repo with your entire app in it - which doesn't really help us narrow down the problem. It would be really helpful if you could remove extraneous stuff to narrow down to the root cause and provide a minimal reproduction. Like I said - 90% of the time that process will uncover the root cause and it will be related to a third party or an extension or something else unique to your application. If it does end up being a problem in core Remix then the minimal reproduction makes it significantly easier for us to triage.

That said, when I pull your repo neither npm run dev nor npm run build/npm run start produce that error for me. So it does seem to be something with your local setup or maybe your local browser extensions. Try running in an incognito window to see if it's browser extension related?

@brophdawg11 brophdawg11 added the needs-response We need a response from the original author about this issue/PR label Apr 19, 2024
@dhavalveera
Copy link
Author

@brophdawg11 is there any way to catch errors? like the error I mentioned, for that to catch like from where this is error is happening? any idea?

@github-actions github-actions bot removed the needs-response We need a response from the original author about this issue/PR label Apr 21, 2024
@dhavalveera
Copy link
Author

That doesn't run for me either unfortunately:

Screenshot 2024-04-19 at 10 00 54 AM

It looks like that's just pulling from a cloned github repo with your entire app in it - which doesn't really help us narrow down the problem. It would be really helpful if you could remove extraneous stuff to narrow down to the root cause and provide a minimal reproduction. Like I said - 90% of the time that process will uncover the root cause and it will be related to a third party or an extension or something else unique to your application. If it does end up being a problem in core Remix then the minimal reproduction makes it significantly easier for us to triage.

That said, when I pull your repo neither npm run dev nor npm run build/npm run start produce that error for me. So it does seem to be something with your local setup or maybe your local browser extensions. Try running in an incognito window to see if it's browser extension related?

Furthermore, I tried to debug in my local again, where I disabled all my Chrome Plugins, and tried but still the issue is still there..

Also, I am using a Remix DevTools Plugin, so I tried to remove it and tried but the issue is still there.

screen-capture.webm

Here is the recording of the issue, I am still encountering...

@dhavalveera
Copy link
Author

Furthermore @brophdawg11 I tried to remove 2 of my Tailwind Library, 1 is flowbite-react and 1 is Preline, I tried to remove it from the places I am using as well as from tailwind.config.ts but the error is still there..

I am using Incognito Mode only, but still I am encountering the issue.

sometimes only by Navigating from one to another or sometime if I am modifying in npm run dev and after saving the changes and if I am changing the page then this error/issue is occurring..

As I mentioned in previous comment, I disabled all the Chrome Extensions and then tried but the error remains there.

@dhavalveera
Copy link
Author

That doesn't run for me either unfortunately:

Screenshot 2024-04-19 at 10 00 54 AM

It looks like that's just pulling from a cloned github repo with your entire app in it - which doesn't really help us narrow down the problem. It would be really helpful if you could remove extraneous stuff to narrow down to the root cause and provide a minimal reproduction. Like I said - 90% of the time that process will uncover the root cause and it will be related to a third party or an extension or something else unique to your application. If it does end up being a problem in core Remix then the minimal reproduction makes it significantly easier for us to triage.

That said, when I pull your repo neither npm run dev nor npm run build/npm run start produce that error for me. So it does seem to be something with your local setup or maybe your local browser extensions. Try running in an incognito window to see if it's browser extension related?


please clone this Repository

I am getting error in such like, go to About Us Page, wait for 2 seconds, modify something in the code, save and the HMR will happen and then go to top and click on home page and it will crash for me as I've shown in the above shared video.

@ClimenteA
Copy link

ClimenteA commented Apr 22, 2024

Same error here.

I'm using the Link component from "@remix-run/react".

image

Here is a traceback:

Error: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.
    at insertBefore (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=4cbe06b4:8457:26)
    at insertOrAppendPlacementNode (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=4cbe06b4:17426:15)
    at commitPlacement (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=4cbe06b4:17382:15)
    at commitReconciliationEffects (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=4cbe06b4:17902:15)
    at commitMutationEffectsOnFiber (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=4cbe06b4:17734:15)
    at recursivelyTraverseMutationEffects (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=4cbe06b4:17681:15)
    at commitMutationEffectsOnFiber (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=4cbe06b4:17695:15)
    at recursivelyTraverseMutationEffects (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=4cbe06b4:17681:15)
    at commitMutationEffectsOnFiber (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=4cbe06b4:17733:15)
    at recursivelyTraverseMutationEffects (http://localhost:5173/node_modules/.vite/deps/chunk-ZRJG7NCB.js?v=4cbe06b4:17681:15)

It appears randomly in dev mode. Probably just a race condition somewhere. If I refresh it works.

@fprl
Copy link

fprl commented Apr 22, 2024

Happens to me as well, and with a brand new npx create-remix@latest

@ironbyte
Copy link

ironbyte commented Apr 23, 2024

@brophdawg11

I can still reproduce the bug consistently. Give this repro repo a shot:

https://github.com/ironbyte/remix-run-issue-9242-repro

issue_9242_repro_video_clip.webm

FAQs:

@cliffordfajardo
Copy link
Contributor

cliffordfajardo commented Apr 24, 2024

@brophdawg11

I can still reproduce the bug consistently. Give this repro repo a shot:

https://github.com/ironbyte/remix-run-issue-9242-repro

issue_9242_repro_video_clip.webm
FAQs:

FYI when downloading @ironbyte 's github repo which has these remix package versions in its package.json file

    "@remix-run/express": "^2.8.1",
    "@remix-run/node": "^2.8.1",
    "@remix-run/react": "^2.8.1",

you'll want to remove the ^ from the front otherwise when you npm install it will fetch the next minor versions published on npm like 2.9.x

since this reproduction was created before the 2.9.0 release, I'm assuming 2.8.1 is the version that ironbyte used and ran into issues with

@ironbyte
Copy link

Updated the repro repo (Pin Remix versions to 2.8.1) - ironbyte/remix-run-issue-9242-repro@960fd8d

BTW, the issue still persists after upgrading Remix deps to 2.9.0 on a separate branch (2.9.0).

image

@jdgamble555
Copy link

possibly related to - #9276

@ironbyte
Copy link

ironbyte commented Apr 25, 2024

It seems that the bug is triggered when navigating back to the index route in any way (using <NavLink> or <Link> or a redirect fn call inside the action) after a Vite HMR update (There has to be a legit file change for this to get triggered).

@justb3a
Copy link

justb3a commented May 8, 2024

Same here, any progress on the topic? remix packages @2.9.1

I can confirm that I can reproduce the behaviour as described above:

  1. trigger Vite HMR update (by changing code)
  2. click <Link> in browser
  3. Application Error -> reload -> everything is fine

Works in both directions.

  • /animals/ -> change something -> navigate in browser to /animals/fox
  • /animals/fox -> change something -> navigate in browser to /animals
DOMException: Node.insertBefore: Child to insert before is not a child of this node
…
The above error occurred in the <meta> component:

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

8 participants