v-if causing "Unhandled error during execution of scheduler flush" after form.post

See original GitHub issue

Versions:

  • @inertiajs/inertia version: 0.8.7
  • @inertiajs/inertia-vue3 version: 0.3.14
  • vue version 3.0.11

Describe the problem:

When posting a form that updates a prop that is being used in a v-if something goes wrong.

Getting a warning with:

[Vue warn]: Unhandled error during execution of scheduler flush. This is likely a Vue internals bug.

Followed by an error:

TypeError: can’t access property “insertBefore”, parent is null

Steps to reproduce:

I’m using Laravel and Vue3. Here’s a component (Route/Index):

<template>
  <!-- here I have a layout component -->
    <form @submit.prevent="form.post(route('route.post'))">
      <button>Create thing</button>
    </form>
    <div v-if="someProp">
      {{ someProp }}
    </div>
   <!-- end of layout component -->
</template>
<script>
import { useForm } from '@inertiajs/inertia-vue3'
export default {
  props: {
    someProp: String
  }
  setup () {
    const form = useForm()
    return { form }
  },
}
</script>

Here’s the laravel controller methods:

public function index()
{
    return Inertia::render('Route/Index', [
        'someProp' => session()->get('propContent'),
    ]);
}

public function store()
{
    // do stuff
    $prop = 'Blabla';
    return redirect()->back()->with('propContent', $prop);
}

Workaround

As a workaround I’m adding { preserveState: false } to form.post and it works.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:22 (3 by maintainers)

github_iconTop GitHub Comments

14reactions
reininkcommented, May 7, 2021

Hey folks, this issue sounds similar to this one: #615

As noted in my comment on that issue, I was able to fix the issue by wrapping by entire page component in an extra <div>. I have a feeling this issue is related to fragments in Vue 3.

Give that a try and let me know?

1reaction
sando57commented, Jul 18, 2021

@reinink I had this exact issue on a new install of Laravel / Jetstream / Inertia.

  • NPM update (Vue 3.0.5 to 3.1.5 and inertia 0.9.1 to 0.9.4) fixed the error
Read more comments on GitHub >

github_iconTop Results From Across the Web

Unhandled error during execution of scheduler flush. This is ...
The error was caused by trying to iterate through a non-iterable (in your case undefined ), using v-for . Specifically, before the call...
Read more >
Vue 3 Error During Execution Of Native Event - ADocLib
Unhandled error during execution of scheduler flush. This is likely a Vue internals bug vue3 whenever the user submits the form and vue....
Read more >
Unhandled error during execution of scheduler flush. This is ...
The error was caused by trying to iterate through a non-iterable (in your case undefined ), using v-for . Specifically, before the call...
Read more >
[vue warn]: failed to resolve component: router-link - You.com
I believe the issue relay on the vue/vue-router versions. ... Vue error makes no sense: Unhandled error during execution of scheduler flush.
Read more >
Bug listing with status RESOLVED with resolution TEST ...
Error in sched.c line 961." status:RESOLVED resolution:TEST-REQUEST severity:major · Bug:22815 - "Gentoo fails to reboot after changes are made to the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found