Unhandled error during execution of scheduler flush this is likely a vue internals bug

I am getting the following error while creating slides in Vue.js: [Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug. Please open an issue at https:...

Arguably, the error message could be improved on this one.

The error was caused by trying to iterate through a non-iterable (in your case undefined), using v-for. Specifically, before the call made in mount() returns, product.product_images is undefined, because you initiate product as empty object.

Vue 2 style solutions

  • instantiate product.product_image as iterable:
//...
  data: () => ({ 
    product: { product_images: [] }
  })

or provide an empty array as fallback in template:

<ion-slide v-for="image in product.product_images || []" v-bind:key="image.id">
  <h1>Slide 1</h1>
</ion-slide> 

or place a v-if on the parent of the v-for:

<ion-slides pager="true" :options="slideOpts" v-if="product.product_images">
  ...
</ion-slides>

Vue 3 style solution

Make the entire ProductDetails component suspensibe, by giving it an async setup function. In the setup function, make the call to get the product.
Proof of concept:

//...
async setup() {
  const product = await fetch("http://localhost:4000/api/products/" + 
    this.$route.params.id, {
      method: "get",
    }).then(r => r.json());
  return { product }
}

Now place <product-details> into a <Suspense>‘s <template #default>, providing a fallback template (which will be rendered while <Suspense> resolves all the async components found in its default template):

<Suspense>
  <template #default>
    <product-details></product-details>
  </template>
  <template #fallback>
    Product is loading...
  </template>
</Suspense>

The beauty (and elegance) of using <Suspense> is that the parent doesn’t need to know the actual condition(s) for which the markup is not yet to be rendered. It simply waits for all suspensible components to resolve.
In short, using <Suspense> you no longer need to hardcode the rendering logic into the template using v-ifs and specifying the condition in clear, on the wrapper. Each async child component contains its own condition and all it announces to the parent is: i’m done. When all are done, they’re rendered.

Well, this is a bug that occurs when using Vue 3.0.7.
If it helps, here is teh stack trace that I get in my version of the code (I am not sure how to get that in jsfiddle):

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/vue-next 
  at <SelectDialog list= (3) ["One", "Two", "Three"] > 
  at <App>
warn @ runtime-core.esm-bundler.js:38
logError @ runtime-core.esm-bundler.js:211
handleError @ runtime-core.esm-bundler.js:203
callWithErrorHandling @ runtime-core.esm-bundler.js:157
flushJobs @ runtime-core.esm-bundler.js:384
Promise.then (async)
queueFlush @ runtime-core.esm-bundler.js:286
queueJob @ runtime-core.esm-bundler.js:280
run @ reactivity.esm-bundler.js:183
trigger @ reactivity.esm-bundler.js:189
set @ reactivity.esm-bundler.js:292
set @ runtime-core.esm-bundler.js:6219
onClick @ SelectDialog.vue:12
callWithErrorHandling @ runtime-core.esm-bundler.js:154
callWithAsyncErrorHandling @ runtime-core.esm-bundler.js:163
invoker @ runtime-dom.esm-bundler.js:308
runtime-dom.esm-bundler.js:175 Uncaught (in promise) DOMException: Failed to execute 'setAttribute' on 'Element': '0' is not a valid attribute name.
    at patchAttr (http://localhost:3000/node_modules/.vite/vue.js?v=2c2f4f03:6789:10)
    at patchProp (http://localhost:3000/node_modules/.vite/vue.js?v=2c2f4f03:6931:9)
    at patchProps (http://localhost:3000/node_modules/.vite/vue.js?v=2c2f4f03:4319:11)
    at patchElement (http://localhost:3000/node_modules/.vite/vue.js?v=2c2f4f03:4257:9)
    at processElement (http://localhost:3000/node_modules/.vite/vue.js?v=2c2f4f03:4156:7)
    at patch (http://localhost:3000/node_modules/.vite/vue.js?v=2c2f4f03:4088:11)
    at patchBlockChildren (http://localhost:3000/node_modules/.vite/vue.js?v=2c2f4f03:4308:7)
    at patchElement (http://localhost:3000/node_modules/.vite/vue.js?v=2c2f4f03:4289:7)
    at processElement (http://localhost:3000/node_modules/.vite/vue.js?v=2c2f4f03:4156:7)
    at patch (http://localhost:3000/node_modules/.vite/vue.js?v=2c2f4f03:4088:11)

#javascript #vue.js #vuejs3

#язык JavaScript #vue.js #vuejs3

Вопрос:

Я попытался выяснить, что происходит с этой конкретной страницей, поскольку каждый раз, когда я ее загружаю, я получаю список предупреждений и сообщение об ошибке

 [Vue warn]: Unhandled error during execution of render function   at lt;MovieDetails id="5" onVnodeUnmounted=fnlt;onVnodeUnmountedgt; ref=Reflt; undefined gt; gt;   at lt;RouterViewgt;   at lt;Appgt;   [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/vue-next   at lt;MovieDetails id="5" onVnodeUnmounted=fnlt;onVnodeUnmountedgt; ref=Reflt; undefined gt; gt;   at lt;RouterViewgt;   at lt;Appgt;  Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'rating')  at Proxy.render (MovieDetails.vue?e6ee:14)  at renderComponentRoot (runtime-core.esm-bundler.js?5c40:444)  at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?5c40:4211)  at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:160)  at setupRenderEffect (runtime-core.esm-bundler.js?5c40:4337)  at mountComponent (runtime-core.esm-bundler.js?5c40:4120)  at processComponent (runtime-core.esm-bundler.js?5c40:4078)  at patch (runtime-core.esm-bundler.js?5c40:3673)  at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?5c40:4288)  at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:160)  5[Violation] Added non-passive event listener to a scroll-blocking lt;somegt; event. Consider marking event handler as 'passive' to make the page more responsive. See lt;URLgt;  [Violation] 'setTimeout' handler took 96ms www-embed-player.js:575   

Все они действительно не имеют для меня никакого смысла, кроме неучтенного (в обещании), и даже в этом я очень не уверен, потому что при загрузке страницы (рейтинг, в котором говорится, что она не может читать, отображается так, как должно). Может ли кто-нибудь сказать мне, что означает это предупреждение и есть ли способ их исправить? Это единственная страница моего проекта, на которой есть эта проблема. Я также оставлю здесь свое мнение, и если кто-нибудь сможет объяснить мне, почему рейтинг выдает ошибку, несмотря на то, что она отображается правильно, это было бы здорово!

 lt;templategt;  lt;div class="movie-details"gt;  lt;div class="route"gt;  lt;h3gt;  lt;router-link to="/movies"gt;  lt;spangt;Movieslt;/spangt;  lt;/router-linkgt;  amp;emsp;/amp;emsp;{{ movie.title }}  lt;/h3gt;  lt;/divgt;   lt;div class="flex row"gt;  lt;h1gt;{{ movie.title }} lt;span class="subtitle"gt;({{ moment(movie.releaseDate).format("YYYY") }})lt;/spangt;lt;/h1gt;  lt;Button title="Edit" @btn-click="editMovie(this.id)" /gt;  lt;/divgt;   lt;div class="flex flex-info info"gt;  lt;span class="details"gt;{{ movie.rating.rating }}lt;/spangt; |  lt;span class="details"gt;{{ movie.movieLength }}lt;/spangt; |  lt;span class="details"gt;{{ movie.genre.genre }}lt;/spangt; |  lt;span class="details"gt;{{ moment(movie.releaseDate).format("D MMMM YYYY") }}lt;/spangt;  lt;/divgt;    lt;div class="youtube"gt;  lt;iframe width="640" height="360" :src="videoEmbed" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreengt;lt;/iframegt;  lt;/divgt;   lt;div class="cast-crew grid"gt;  lt;div class="director"gt;  lt;h2gt;Directed By:lt;/h2gt;    lt;router-link :to="{name: 'DirectorDetails', params: {id: movie.director.id }}"gt;  lt;ListItemgt;  {{ movie.director.firstName }} {{ movie.director.lastName }}  lt;/ListItemgt;  lt;/router-linkgt;  lt;/divgt;  lt;aside class="cast"gt;  lt;h2gt;Actors:lt;/h2gt;  lt;div class="actors grid"gt;  lt;div :key="actor.id" class="actor" v-for="actor in movie.actors"gt;  lt;router-link :to="{name: 'ActorDetails', params: {id: actor.id}}"gt;  lt;ListItemgt;  {{ actor.firstName }} {{ actor.lastName }}  lt;/ListItemgt;  lt;/router-linkgt;  lt;/divgt;  lt;/divgt;  lt;/asidegt;  lt;/divgt;  lt;/divgt; lt;/templategt;  lt;scriptgt;  import moment from "moment";  import Button from "@/components/Button.vue";  import ListItem from "@/components/ListItem.vue";   export default {  components: {  Button,  ListItem,  },  props: [  "id"  ],  data() {  return {  movie: {},  moment,  videoEmbed: "https://www.youtube.com/embed/"  };  },  methods: {  editMovie(id) {  this.$router.push({name: "EditMovie", params: { id: id }});  },  async fetchMovie(id) {  const res = await fetch(`api/movies/${id}`);  const data = await res.json();   return data;  }  },  async created() {  this.movie = await this.fetchMovie(this.id);    //eslint-disable-next-line  const reg = new RegExp('.*?=s*(.*)');  const split = reg.exec(this.movie.trailerUrl);  this.videoEmbed  = split[1];  }  } lt;/scriptgt;  lt;style scopedgt;  h1 {  font-weight: bold;  }   .subtitle {  font-weight: 400;  font-size: 1rem;  }   .info {  font-weight: 300;  letter-spacing: 1px;  }   .details {  margin: 0 0.8rem;  }   .details:first-child {  margin-left: 0;  }   .details:last-child {  margin-right: 0;  }   .youtube {  margin: 1.5rem 0;  display: flex;  }   .youtube iframe {  justify-self: flex-start;  border-radius: 8px;  }   .cast-crew {  height: 110%;  }   .cast-crew.grid {  grid-template-columns: auto 75%;  }   .cast-crew a {  font-weight: bold;  font-size: 1.125rem;  }   .director {  align-self: flex-start;  text-align: left;  }   .cast {  padding-left: 1.5rem;  text-align: left;  border-left: 2px solid #000;  align-self: flex-start;  }   .actors.grid {  grid-template-rows: repeat(4, 1fr);  grid-template-columns: auto;  gap: 0.75rem;  grid-auto-flow: column;  justify-content: flex-start;  } lt;/stylegt;  

Ответ №1:

Используйте метод lodash get для исправления неопределенной ошибки

  lt;scriptgt; import _ from 'lodash'; export default { methods: {  getValue(object, string, defaultValue = ''): {  return _.get(object, string, defaultValue)  } } lt;/scriptgt; lt;templategt;  {{ getValue(movie, 'rating.rating') }} lt;/templategt;   

вы можете сделать его глобальным помощником для последующего использования в шаблоне

Issue Title Created Date Comment Count Updated Date
Deterministic maximums 0 2022-12-30 2023-02-05
bump java version to 8 research issue 3 2023-01-03 2023-01-20
chore: adjust border color on outline button and dropdown components 0 2023-01-03 2023-02-09
wakuv2: add Nameserver to WakuV2Config 0 2023-01-03 2023-02-10
Keyboard is not opened on reply or editing message in chats (Android) 1 2022-12-30 2023-01-12
error with complex number u0 in OptimizationOptimisers 2 2022-08-31 2023-02-12
Reading F-Series chips? (F120, F270, F270, F370) 2 2020-04-20 2022-09-06
Stratasys Fortus 450mc 80 2017-07-07 2023-02-09
Use fixed-width digits 6 2022-09-15 2022-12-25
Does not save videos to YouTube 3 2021-12-29 2023-02-05
Support for logging various templated classes 5 2022-10-04 2023-02-05
[BUG] Add «UK» to whitelist 5 2022-01-01 2023-02-12
v7.1.0 删除内容,提示channelid不存在 0 2022-01-08 2023-02-11
A nonexistent file in _config.yml 1 2021-05-29 2023-02-12
both building=yes and included building:part=yes are rendered on top of each other 4 2021-01-31 2023-01-16
server list 顺序不同 会导致请求的结果不同 3 2022-05-03 2023-02-07
Throw error when parameterLimit is crossed 1 2020-07-31 2023-01-23
Unable to authenticate to container registry 3 2022-11-07 2023-02-05
file with the same name will not check md5 4 2022-11-08 2023-02-04
Mix Not Compiling All Assets — Still Says Successful 1 2022-05-19 2023-02-02
Terminal view POS app doesn’t show BTCPay logo anymore 2 2021-10-13 2022-12-12
http://localhost:8000/artipub-helper.zip 登录助手404 2 2021-03-08 2023-02-06
Not able to copy 3rd and later messages that sent by element-desktop 0 2022-11-17 2023-01-26
Next.js hot reload and MySQL Error “Too many connections” 0 2022-09-21 2023-01-28
swap two quick install steps 1 2021-12-17 2023-01-24
Docker configuration 5 2021-12-15 2023-01-24
Security: Implement CGO binary hardening 0 2022-03-25 2023-02-09
Markdown metadata support 7 2015-01-27 2023-02-03
[Bug] minimal aws cluster does not launch 5 2021-11-13 2023-01-26
Consider referencing GCP metadata service by IP in Ignition/Afterburn 5 2021-07-07 2023-01-22
Enhance regen_doc.g to inform about methods which are not used 1 2021-04-07 2023-01-15
Invalid $filter query error — getAllMessages endpoint 4 2022-09-27 2023-01-16
Fix appprotoexec go:build tags 2 2023-02-01 2023-02-09
Support exercising choices on interfaces in Navigator 1 2022-08-18 2023-02-03
Unordered list inside an ordered list 4 2019-11-22 2023-02-12
Make name checking for anonymous (public) users more inclusive so that people don’t have to invent a name 1 2021-09-12 2023-01-29
Routing issue (should be routed to AMS, instead routed to FRA) 21 2022-05-27 2023-01-25
Import aliases do not work for generated `$types`, must use relative path instead. 3 2022-10-17 2022-10-19
@sveltejs/adapter-static causes vite build —watch to fail 0 2022-10-15 2022-10-19
How to emit event into frontend with menu items ? 2 2021-07-20 2023-02-07
Requirement of Bucket Usage and Performance Promethues metrics 4 2021-01-11 2023-02-04
Tile description overflows 2 2022-04-11 2022-09-25
网页服务是nginx时,升级固件上传失败! 7 2022-12-06 2023-02-01
Client Allocation Request for: Hedra Labs 2 2022-05-26 2023-02-02
Regression: Quick action add track waypoint: Not possible anymore to set waypoint name 2 2022-05-23 2023-01-24
Unusual routing recalculation resulting in wrong-way routing that retraces part of the original route 5 2022-05-22 2023-01-24
[Bug]: Maintenance generateLowQualityPreview issue stream_get_meta_data(): Argument #1 ($stream) must be of type resource, null given 5 2022-04-14 2023-02-10
Unknown connection name in queues 0 2021-11-24 2023-02-05
Is the data sequence strictly following with a time series? 1 2020-10-19 2022-11-19
Agenda — Double-clicking causes knob to open/close 1 2022-07-03 2023-02-02

I think this problem stems from a parent template having multiple children in Vue.js 3 with Vue Router 4. I never had this problem in prior version of both packages.

I have a simple App.vue file:

<template>
    <div id="app">
         <main id="content">
                    <div id="nav">
                        <!--<router-link to="/about">About</router-link>-->
                        <router-link to="/information">Information</router-link>
                        <router-link :to="{ path: '/create', name: 'PostCreate'}">Create</router-link>
                    </div>
                    <router-view></router-view>
         </main>
</template>

The router-link to="/information" link works fine. It just loads the view which has no other components inside it.

The other router-link :to="{ path: '/create', name: 'PostCreate'}" fails after repeatedly trying to load the component about 50 times and logs this in the console:

 [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/vue-next 
  at <PostCreate> 
  at <PostCreate>  
  at <PostCreate>  
  ... // repeats over and over again until
  at <PostCreate onVnodeUnmounted=fn<onVnodeUnmounted> ref=Ref< null > > 
  at <RouterView> 
  at <App> 
  at <App>

vuerouter.js

const routes = [
    {
        path: '/',
        name: 'HomeView',
        component: HomeView
    },
    {
        path: '/information',
        name: 'Information',
        component: () => import(/* webpackChunkName: "Information" */ '../views/information/Information.vue')
    }
    ,
    {
        path: '/create',
        name: 'PostCreate',
        component: () => import(/* webpackChunkName: "Create" */ '../views/posts/PostCreate.vue')
    }
];

The only difference between Information.vue and PostCreate.vue is that the latter imports another vue component to make a form for the user to create a post.

Information.vue

<template>
<div>
<p>I am full of good info</p>
</div>
</template>
<script>
    export default {
        name: 'Information'
    }
</script>

PostCreate.vue

<template>
    <div class="content">

            <h1>I make a form</h1>
            <Post-Create></Post-Create>

    </div>
</template>

<script>
    import PostCreate from "../../components/PostCreate.vue";

    export default {
        name: "PostCreate",
        components: {
            "Post-Create": PostCreate
        }
    }
</script>

Why is this an issue in Vue.js 3 with Vue-Router 4 whereas it worked fine previously? How do I solve it?

Понравилась статья? Поделить с друзьями:
  • Unhandled error during execution of render function
  • Unhandled error during execution of component event handler
  • Unhandled dynamic native error
  • Unfortunately an error has occurred yandere simulator
  • Unexpected error opening catalog lightroom ошибка