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

TypeError: Cannot read properties of null (reading 'parentNode') #13309

Closed
nurdism opened this issue Jan 29, 2022 · 292 comments · Fixed by #21450
Closed

TypeError: Cannot read properties of null (reading 'parentNode') #13309

nurdism opened this issue Jan 29, 2022 · 292 comments · Fixed by #21450

Comments

@nurdism
Copy link

nurdism commented Jan 29, 2022

Environment


  • Operating System: Linux
  • Node Version: v14.18.1
  • Nuxt Version: 3.0.0-27389502.88da719
  • Package Manager: yarn@1.22.17
  • Bundler: Vite
  • User Config: ssr
  • Runtime Modules: -
  • Build Modules: -

Reproduction

use this sandbox, Visit ${url}/organization/365824000000000003/template/new click on the "a" link then the "b" link and this error is thrown:

runtime-core.esm-bundler.js:38 [Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core 
  at <Transition name="page" mode="out-in" > 
  at <Dashboard name="dashboard" > 
  at <AsyncComponentWrapper name="dashboard" > 
  at <NuxtLayout name="dashboard" > 
  at <BaseTransition mode="out-in" appear=false persisted=false  ... > 
  at <Transition name="layout" mode="out-in" > 
  at <RouterView > 
  at <NuxtPage> 
  at <App> 
  at <NuxtRoot>
runtime-dom.esm-bundler.js:35 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'parentNode')
    at parentNode (runtime-dom.esm-bundler.js:35:30)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5109:17)
    at ReactiveEffect.run (reactivity.esm-bundler.js:160:29)
    at updateComponent (runtime-core.esm-bundler.js:4968:26)
    at processComponent (runtime-core.esm-bundler.js:4901:13)
    at patch (runtime-core.esm-bundler.js:4489:21)
    at patchKeyedChildren (runtime-core.esm-bundler.js:5262:17)
    at patchChildren (runtime-core.esm-bundler.js:5205:21)
    at processFragment (runtime-core.esm-bundler.js:4886:17)
    at patch (runtime-core.esm-bundler.js:4482:17)

Describe the bug

hooks page:start and page:finish don't seem to fire on pages ${url}/organization/* and an error is thrown when using await in the <script setup> and then navigating to a new page.

I don't know if this is due to the page structure or the the way the pages are set up. It's taken me all day to get this error to reproduce and the only way I've gotten this to throw is with this folder structure and by

  • first visiting a page that doesn't use await in the <script setup>
  • then visiting a page that does uses await
  • then by using vue-router to navigate to another page

Additional context

No response

Logs

No response

Tasks

No tasks being tracked yet.
@nurdism nurdism changed the title Cannot read properties of null (reading 'parentNode') TypeError: Cannot read properties of null (reading 'parentNode') Jan 29, 2022
@rvmourik
Copy link
Contributor

Don't now if it is helpful, but I experienced some similar errors while developing our app. In the end it was caused by a transition component as the root component in the template. Navigating between routes sometimes caused the parentNode issue.

Also our pages setup looks a lot like yours, so maybe it is helpful :-)

@nurdism
Copy link
Author

nurdism commented Jan 30, 2022

@rvmourik is on the right track, I went ahead and recreated the <NuxtPage /> component, when I remove the <Transition /> before the <NuxtLayout /> the error does not pop up, but the page:start and the page:finish are still not firing

@rvmourik
Copy link
Contributor

@rvmourik is on the right track, I went ahead and recreated the <NuxtPage /> component, when I remove the <Transition /> before the <NuxtLayout /> the error does not pop up, but the page:start and the page:finish are still not firing

I did the exact same thing to work around the error, it might be related to the combination of dynamic routes and nested pages.

@anburocky3
Copy link

I too face the same problem, i did created a div parent of app.vue and the link is navigating now, but i see the following error consoled.

vue.js?v=2018aa88:103 [Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core 
  at <Anonymous> 
  at <App key=1 > 
  at <NuxtRoot>
warn @ vue.js?v=2018aa88:103
logError @ vue.js?v=2018aa88:257
handleError @ vue.js?v=2018aa88:249
callWithErrorHandling @ vue.js?v=2018aa88:206
flushJobs @ vue.js?v=2018aa88:396
Promise.then (async)
queueFlush @ vue.js?v=2018aa88:311
queueJob @ vue.js?v=2018aa88:305
(anonymous) @ vue.js?v=2018aa88:4057
triggerEffects @ chunk-ABITFNDB.js?v=2018aa88:571
triggerRefValue @ chunk-ABITFNDB.js?v=2018aa88:1072
(anonymous) @ chunk-ABITFNDB.js?v=2018aa88:1196
triggerEffects @ chunk-ABITFNDB.js?v=2018aa88:571
triggerRefValue @ chunk-ABITFNDB.js?v=2018aa88:1072
(anonymous) @ chunk-ABITFNDB.js?v=2018aa88:1196
triggerEffects @ chunk-ABITFNDB.js?v=2018aa88:571
triggerRefValue @ chunk-ABITFNDB.js?v=2018aa88:1072
(anonymous) @ chunk-ABITFNDB.js?v=2018aa88:1196
triggerEffects @ chunk-ABITFNDB.js?v=2018aa88:571
triggerRefValue @ chunk-ABITFNDB.js?v=2018aa88:1072
(anonymous) @ chunk-ABITFNDB.js?v=2018aa88:1196
triggerEffects @ chunk-ABITFNDB.js?v=2018aa88:571
triggerRefValue @ chunk-ABITFNDB.js?v=2018aa88:1072
set value @ chunk-ABITFNDB.js?v=2018aa88:1115
finalizeNavigation @ vue-router.esm-bundler.js?v=2018aa88:3194
(anonymous) @ vue-router.esm-bundler.js?v=2018aa88:3067
Promise.then (async)
pushWithRedirect @ vue-router.esm-bundler.js?v=2018aa88:3038
push @ vue-router.esm-bundler.js?v=2018aa88:2966
navigate @ vue-router.esm-bundler.js?v=2018aa88:2093
callWithErrorHandling @ vue.js?v=2018aa88:204
callWithAsyncErrorHandling @ vue.js?v=2018aa88:212
invoker @ vue.js?v=2018aa88:6193
vue.js?v=2018aa88:5960 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'parentNode')
    at parentNode (vue.js?v=2018aa88:5960:30)
    at ReactiveEffect.componentUpdateFn [as fn] (vue.js?v=2018aa88:4035:35)
    at ReactiveEffect.run (chunk-ABITFNDB.js?v=2018aa88:399:19)
    at callWithErrorHandling (vue.js?v=2018aa88:204:32)
    at flushJobs (vue.js?v=2018aa88:396:9)

Is this vue bug?

@danielroe
Copy link
Member

The original reproduction now longer gives this error, when wrapping <NuxtPage>:

  <template>
+   <div>
      <NuxtPage />
+   </div>
  </template>

See https://codesandbox.io/s/immutable-fast-kv6yh0

@anburocky3
Copy link

Yes, I was having my code like this

<template>
    <NuxtLayout>
        <NuxtPage />
    </NuxtLayout>
</template>

Wrapping the <NuxtLayout> with div fixed the issue.

@Guovin
Copy link

Guovin commented Apr 21, 2022

@danielroe @anburocky3 I ran into this problem too, adding div wraps to NuxtPage didn't fix it either. Router. push or NuxtLink can be used to jump to the page normally. However, if you jump to the page after refreshing the browser, a parentNode problem will occur. Finally, refresh the browser to display the page.

@anburocky3
Copy link

@danielroe @anburocky3 I ran into this problem too, adding div wraps to NuxtPage didn't fix it either. Router. push or NuxtLink can be used to jump to the page normally. However, if you jump to the page after refreshing the browser, a parentNode problem will occur. Finally, refresh the browser to display the page.

Any reproduction steps? Try to upgrade to nuxt3 latest and retry it.

@Guovin
Copy link

Guovin commented Apr 21, 2022

I'm using the latest version of Nuxt3, which I suspect is due to useLazyAsyncData. When I used Axios, I had 500 errors when I refreshed the page. To solve this problem, I used useLazyAsyncData to get the request data, but after refreshing the page, I couldn't redirect the route.

I'm using the latest version of Nuxt3, which I suspect is due to useLazyAsyncData. When I used Axios, I get a 500 error when I refreshed the page. To solve this problem, I used useLazyAsyncData to get the request data, but after refreshing the page, I couldn't redirect the route.

@Guovin
Copy link

Guovin commented Apr 22, 2022

@danielroe @anburocky3 I ran into this problem too, adding div wraps to NuxtPage didn't fix it either. Router. push or NuxtLink can be used to jump to the page normally. However, if you jump to the page after refreshing the browser, a parentNode problem will occur. Finally, refresh the browser to display the page.

Any reproduction steps? Try to upgrade to nuxt3 latest and retry it.

Finally, I close SSR and solve this problem.

@potatozerg
Copy link

My local works fine, but when I deploy on dev(firebase), I got the same error whenever I route to another page.

@tinegaCollins
Copy link

@danielroe @anburocky3 I ran into this problem too, adding div wraps to NuxtPage didn't fix it either. Router. push or NuxtLink can be used to jump to the page normally. However, if you jump to the page after refreshing the browser, a parentNode problem will occur. Finally, refresh the browser to display the page.

Any reproduction steps? Try to upgrade to nuxt3 latest and retry it.

Finally, I close SSR and solve this problem.

i am using nuxt3 but i am still getting this error

@tinegaCollins
Copy link

i created a new nuxt application and transferred my files to the new application following the rules from the nuxt3 docs. problem fixed.

@aurendev
Copy link

i created a new nuxt application and transferred my files to the new application following the rules from the nuxt3 docs. problem fixed.

how ?

@rvmourik
Copy link
Contributor

i created a new nuxt application and transferred my files to the new application following the rules from the nuxt3 docs. problem fixed.

how ?

make sure when a component like NuxtLayout or NuxtPage is the root-node (first in template) to be wrapped within a div.

@pavloskafritsas
Copy link

pavloskafritsas commented Jun 25, 2022

i created a new nuxt application and transferred my files to the new application following the rules from the nuxt3 docs. problem fixed.

how ?

make sure when a component like NuxtLayout or NuxtPage is the root-node (first in template) to be wrapped within a div.

In my case this bug occurs when switching between pages with different layouts defined in definePageMeta, regardless the parent of NuxtPage element.

@jshimkoski
Copy link

jshimkoski commented Jun 29, 2022

Same issue. Wrapping NuxtLayout in a <div> doesn't help.

Dynamic routes in question look like this:

  • Parent page: /pages/test/[id].vue
  • Child page: /pages/test/[id]/index.vue

Parent page has <NuxtPage :something="something" /> wrapped in a <div>.

I can navigate to the dynamic route twice, then on the third time, I get the [Vue warn]: Unhandled error during execution of scheduler flush. warning and the Uncaught (in promise) TypeError: Cannot read properties of null (reading 'parentNode') error.

@tinegaCollins
Copy link

try wrapping all the elements on the page in one single element
the NUXTlayout should be in the div

@kstraszewski
Copy link

I am getting excaly the same error when try to navigate between routes. All my pages have this structure:
image

@n00kii
Copy link

n00kii commented Jul 25, 2022

I am also having this error, was there any resolution reached? my pages/ looks like this:

pages
└── [group]
    ├── index.vue
    └── [id].vue

and my app.vue is this: (the <v-xxx> components are of the vuetify library)

<v-app>
    <Header />
    <v-main>
        <v-container class="my-4">
            <NuxtLayout>
                <NuxtPage />
            </NuxtLayout>
        </v-container>
    </v-main>
    <Footer />
</v-app>

When I generate my app (target: static) and try to navigate to a page/[group] from the home page, this error appears and navigation fails. If I then refresh, I can navigate freely across all of my application, until I refresh again while on the home page.

@Fred-grais
Copy link

Any news on this? I'm having the same exact error in my Nuxt3 RC 6 app

@adamkasper
Copy link

In RC 8 still the same problem

@codeflorist
Copy link

apart from this solution provided by @danielroe ...

  <template>
+   <div>
      <NuxtPage />
+   </div>
  </template>

... i found that components having another component as their root-element also was cause of this problem. wrapping these with a html-element (e.g. div) solved the problem for me.

@itsalimanuel
Copy link

Fixed with :

definePageMeta({
  layoutTransition: true,
});

@tdebooij
Copy link

tdebooij commented Feb 1, 2024

Wrapping all NuxtLayouts in divs throughout the app helped me. Look if some pages in your application use NuxtLayout, not just the home page.

This was it for me as well, I had a root <NuxtLayout> in my Error.vue that was causing the issue.

@HADB
Copy link

HADB commented Feb 2, 2024

This error happens again after upgrade vue from 3.4.1 to 3.4.15. Happens when changing routers.
Nuxt version: 3.10.0.

image

@tolgahanbeyazoglu
Copy link

@HADB There was no problem in my tests, there may be a different event in your code, this parent node error was occurring in continuous request in data fetching operations, they closed this situation with version 3.4

@HADB
Copy link

HADB commented Feb 2, 2024

@HADB There was no problem in my tests, there may be a different event in your code, this parent node error was occurring in continuous request in data fetching operations, they closed this situation with version 3.4

@tolgahanbeyazoglu Thanks for replying. I found my problem is linked to this issue(#25214) which seems the same error but diferrent situation.

@tolgahanbeyazoglu
Copy link

@HADB yes not the same problems yours diffrerent problem

@Namstel
Copy link

Namstel commented Feb 2, 2024

Fixed with :

definePageMeta({
  layoutTransition: true,
});

This worked for me as well, but resulted in a blank page between transition.

Finally I wrapped all of the NuxtLayout elements in my app in a div and that fixed it for me without the blank page in between. So weird.

@PrimeTimeTran
Copy link

By playing around with my nuxt.config.js file I fixed it(along with doing the other suggested things.

routeRules: {
    '/': { prerender: true },
    '/theme/**': { prerender: true },
    '/articles/**': { prerender: true },
    '/administrator/**': { ssr: false },
    '/api/**': { cors: true, ssr: false },
  },
  nitro: {
    prerender: {
      routes: ['/', '/articles/**', '/theme/**'],
    },
  },

Not sure if it'll be helpful to others so just giving it a shot. I had to use routeRules to make the error go away(in production build which is deployed to prod the navigation doesn't work(throws the OPs error)) I added prerender to false or true as appropriate and then it stopped complaining for me.

@Maxbsy
Copy link

Maxbsy commented Feb 4, 2024

Using the specified vue3.4.8 can solve the problem for me, but if not, the problem still exists. Can we solve the problem at its root?

@letstri

This comment was marked as off-topic.

@pocketChao
Copy link

我的本地工作正常,但是当我在 dev(firebase) 上部署时,每当路由到另一个页面时,我都会遇到相同的错误。

Has it been settled at last

@RedLionHeart
Copy link

Worked for me:
I just added <NuxtLoadingIndicator /> to the page, from which there was an error

@awacode21
Copy link

i was dealing with the same issue. None of the mentioned workarounds fixed it for me.
After updating to latest Nuxt (3.10.1) it was fixed for me

@meinor25
Copy link

meinor25 commented Feb 8, 2024

I also was dealing with this issue, fixed it wrapping all the <NuxtLayout /> used on my pages with a <div>.

  • using Nuxt (3.10.1)

@zavodptica
Copy link

Hi all. I had a problem when navigating between pages with changing layouts.
I have little experience and I will be glad if you point out errors.
I solved this problem for myself by wrapping <slot/> in <suspense>

~/layouts/example.vue

<template>
  <div>
    <p>Example layout</p>
    <suspense>
       <slot/>
    </suspense>
  </div>
</template>

@ufukcam
Copy link

ufukcam commented Feb 11, 2024

Hi all, Has anyone definitely solved this problem?

@eatsmarter-benny
Copy link

eatsmarter-benny commented Feb 12, 2024

We also are still affected by this problem and would like to see this issues re-opened.

Nuxt 3.10.1 is not a fix for this issue.

Tips like adding extra <div>s or changing the HTML structure with a different layout and so on are non-solutions for us because we don't want to change the source code we want to have as a replacement for a problem fix (combat symptoms).

Out tests strengthen the hypothesis that the Vue.js core library is the culprit.
Adding vue@v3.4.8, effectively overwriting the version brought in by Nuxt (which is newer) fixes the problem for us.

Is this problem known to the Vue.js folks and is that problem on their roadmap already?

@manniL
Copy link
Member

manniL commented Feb 12, 2024

We also are still affected by this problem and would like to see this issues re-opened.

This is still a Vue upstream bug and not a Nuxt issue.

@Jupriadi
Copy link

Reproduksi asli sekarang lebih lama memberikan kesalahan ini, ketika membungkus <NuxtPage>:

  <template>
+   <div>
      <NuxtPage />
+   </div>
  </template>

Lihat https://codesandbox.io/s/immutable-fast-kv6yh0

Environment

  • Operating System: Linux
  • Node Version: v14.18.1
  • Nuxt Version: 3.0.0-27389502.88da719
  • Package Manager: yarn@1.22.17
  • Bundler: Vite
  • User Config: ssr
  • Runtime Modules: -
  • Build Modules: -

Reproduction

use this sandbox, Visit ${url}/organization/365824000000000003/template/new click on the "a" link then the "b" link and this error is thrown:

runtime-core.esm-bundler.js:38 [Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core 
  at <Transition name="page" mode="out-in" > 
  at <Dashboard name="dashboard" > 
  at <AsyncComponentWrapper name="dashboard" > 
  at <NuxtLayout name="dashboard" > 
  at <BaseTransition mode="out-in" appear=false persisted=false  ... > 
  at <Transition name="layout" mode="out-in" > 
  at <RouterView > 
  at <NuxtPage> 
  at <App> 
  at <NuxtRoot>
runtime-dom.esm-bundler.js:35 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'parentNode')
    at parentNode (runtime-dom.esm-bundler.js:35:30)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5109:17)
    at ReactiveEffect.run (reactivity.esm-bundler.js:160:29)
    at updateComponent (runtime-core.esm-bundler.js:4968:26)
    at processComponent (runtime-core.esm-bundler.js:4901:13)
    at patch (runtime-core.esm-bundler.js:4489:21)
    at patchKeyedChildren (runtime-core.esm-bundler.js:5262:17)
    at patchChildren (runtime-core.esm-bundler.js:5205:21)
    at processFragment (runtime-core.esm-bundler.js:4886:17)
    at patch (runtime-core.esm-bundler.js:4482:17)

Describe the bug

hooks page:start and page:finish don't seem to fire on pages ${url}/organization/* and an error is thrown when using await in the <script setup> and then navigating to a new page.

I don't know if this is due to the page structure or the the way the pages are set up. It's taken me all day to get this error to reproduce and the only way I've gotten this to throw is with this folder structure and by

  • first visiting a page that doesn't use await in the <script setup>
  • then visiting a page that does uses await
  • then by using vue-router to navigate to another page

Additional context

No response

Logs

No response

Tasks

Beta
Give feedback
No tasks being tracked yet.

  1. [ ]

    Options

      * Convert to issue
      * Toggle completion
      * Rename
      * Remove
    

helo @nurdism is your problem solved.? if yes, how to solve this problem.? i found this problem now, and hasn't solved long time... pleas tell me how to solve this problem if you don't mind...

@alvarobelmonte
Copy link

@Jupriadi Adding vue v3.4.8 solved it in my case

@Nizami9
Copy link

Nizami9 commented Feb 23, 2024

Hi guys.

In my case, this error appeared during the layout change. My project was saved by installing this vue version:

npm i vue@v3.4.8

That really helped!

@lkjimy
Copy link

lkjimy commented Feb 23, 2024

@Jupriadi Adding vue v3.4.8 solved it in my case

This one worked for me. Thanks!

@tusieunhan
Copy link

@Jupriadi Thanks for your solution. It worked <3

@daniluk4000
Copy link
Contributor

FYI all: Vue v3.4.20 has released with this bug fixed.

@ferdinandfrank
Copy link

ferdinandfrank commented Feb 29, 2024

I'm still experiencing this issue on the latest Nuxt v3.10.3 and Vue v3.4.21.

The issue seems to only appear when navigating to dynamic pages.
Usually, I can navigate to the dynamic route once, then on the second or third time, I get the TypeError: Cannot read properties of null (reading 'parentNode') error.

Edit: My issue was caused by loading remote data via fetch within a watcher on the target page. By moving the fetch call out of the watcher, the error is gone as well as all other Cannot read properties of null (reading 'parentNode') errors. Therefore, I can confirm that Vue >= v3.4.20 really fixed this bug on my app as well. 🥳

@rushapushp
Copy link

Hi all. I had a problem when navigating between pages with changing layouts. I have little experience and I will be glad if you point out errors. I solved this problem for myself by wrapping <slot/> in <suspense>

~/layouts/example.vue

<template>
  <div>
    <p>Example layout</p>
    <suspense>
       <slot/>
    </suspense>
  </div>
</template>

**helped for nuxt 3.10.2 **

брат ты легенда

@xak2000
Copy link

xak2000 commented Mar 20, 2024

I also was dealing with this issue, fixed it wrapping all the <NuxtLayout /> used on my pages with a <div>.

To clarify: wrapping <NuxtLayout /> with a <div> means not this:

<template>
  <NuxtLayout>
    <div>The contents</div>
  </NuxtLayout>
</template>

But this:

<template>
  <div>
    <NuxtLayout>The contents</NuxtLayout>
  </div>
</template>

I.e. you need to wrap the <NuxtLayout /> tag itself, not the contents of the of the <NuxtLayout /> tag.

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

Successfully merging a pull request may close this issue.