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

Unhandled error during execution of scheduler flush. Caused by computed #2819

Closed
lukaskoeller opened this issue Dec 14, 2020 · 13 comments
Closed

Comments

@lukaskoeller
Copy link

lukaskoeller commented Dec 14, 2020

Version

3.0.4

Reproduction link

https://jsfiddle.net/Lb9gtx0w/2/

Steps to reproduce

Create a setup() function or computed: property and return a computed property of name type with value either "router-link" or "button". This computed property is then bind to the components attribute is.

What is expected?

The value of type is bind to the is attribute and no error/infinite loop is caused.

What is actually happening?

setup() is called again and again till the app is crashing.
Following errors are appearing:

runtime-core.esm-bundler.js?5c40: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 <Button to="" fullWidth="true" class="full-width button" > 
  at <KeepAlive class="full-width button" > 
  at <Button to="" fullWidth="true" class="full-width button" > 
  at <KeepAlive class="full-width button" > 
  at <Button to="" fullWidth="true" class="full-width button" > 
  at <KeepAlive class="full-width button" > 

...and so on.

Uncaught (in promise) RangeError: Maximum call stack size exceeded
    at renderComponentRoot (runtime-core.esm-bundler.js?5c40:819)
    at componentEffect (runtime-core.esm-bundler.js?5c40:4193)
    at reactiveEffect (reactivity.esm-bundler.js?a1e9:42)
    at effect (reactivity.esm-bundler.js?a1e9:17)
    at setupRenderEffect (runtime-core.esm-bundler.js?5c40:4176)
    at mountComponent (runtime-core.esm-bundler.js?5c40:4134)
    at processComponent (runtime-core.esm-bundler.js?5c40:4094)
    at patch (runtime-core.esm-bundler.js?5c40:3715)
    at componentEffect (runtime-core.esm-bundler.js?5c40:4211)
    at reactiveEffect (reactivity.esm-bundler.js?a1e9:42)

Code excerpt

<template>
  <keep-alive>
    <component
      :is="type"
      :to="to"
      :fullWidth="fullWidth"
      :class="
        fullWidth
          ? 'full-width'
          : ''
      "
      class="button">
      <slot />
    </component>
  </keep-alive>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue';

export default defineComponent({
  name: 'Button',
  props: {
    to: {
      required: false,
      default: '',
    },
    fullWidth: { required: false },
  },
  setup(props) {
    const type = computed(() => (props.to ? 'router-link' : 'button'));

    return {
      type,
    };
  },
});
</script>
@lukaskoeller
Copy link
Author

lukaskoeller commented Dec 14, 2020

@lukaskoeller lukaskoeller changed the title Unhandled error during execution of scheduler flush. Caused by computed value Unhandled error during execution of scheduler flush. Caused by computed Dec 14, 2020
@posva
Copy link
Member

posva commented Dec 14, 2020

Read https://new-issue.vuejs.org/?repo=vuejs/vue#why-repro and open a new issue with a finished repro on that jsfiddle

@posva posva closed this as completed Dec 14, 2020
@lukaskoeller
Copy link
Author

@posva you are totally right. I tried to replicate it in JSfiddle, but I couldn't. It is working there (https://jsfiddle.net/au6ot9yh/).
Nonetheless, the above described component <Button> is still showing the Error. I have another component <BottomButton>, with only negligible differences, that also doesn't show this error.

GitHub Repo

Differences between <Button> and <BottomButton>

  1. Name is different
  2. class name for styling is different

<BottomButton>

<template>
  <component :is="type" :to="to" class="bottom-button">
    <slot />
  </component>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue';

export default defineComponent({
  name: 'BottomButton',
  props: {
    to: {
      required: false,
    },
  },
  setup(props) {
    const type = computed(() => (props.to ? 'router-link' : 'button'));

    return {
      type,
    };
  },
});
</script>

<style scoped>
.bottom-button {
  display: grid;
  place-items: center;
  height: 100%;
  padding: var(--spacing-7) var(--spacing-4);
  background-color: var(--primary-color-lighten-2);
  color: var(--text-color);
  text-decoration: none;
  border: none;

  font-size: var(--base-font-size);
}
</style>

<Button>

<template>
  <component :is="type" :to="to" class="button">
    <slot />
  </component>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue';

export default defineComponent({
  name: 'Button',
  props: {
    to: {
      required: false,
    },
  },
  setup(props) {
    const type = computed(() => (props.to ? 'router-link' : 'button'));

    return {
      type,
    };
  },
});
</script>

<style scoped>
.button {
  display: inline-block;
  padding: var(--spacing-7) var(--spacing-4);
  background-color: var(--primary-color-lighten-2);
  color: var(--text-color);
  border-radius: var(--button-radius);
  text-align: center;
  text-decoration: none;
  border: none;
  cursor: pointer;
  overflow: hidden;

  box-shadow: inset 0px 0px 0px 2px var(--primary-color-lighten-6);

  font-size: var(--button-font-size);
  transition: var(--transition);
}

.button:hover {
  background-color: var(--highlight-color);
}

.full-width {
  width: 100%;
}
</style>

@lukaskoeller
Copy link
Author

Now I created another component <TestButton> that only differs from <Button> that its name: is accordingly. Implemented the same way <TestButton> is also showing no error anymore...

@lukaskoeller
Copy link
Author

lukaskoeller commented Dec 15, 2020

What is causing the error:

✅ Works fine

export default defineComponent({
  name: 'TestButton',

🚫 Causing above described error

export default defineComponent({
  name: 'Button',

@lukaskoeller
Copy link
Author

Couldn't replicate the problem in a new vue-cli project. Really weird!

@andre-cgn
Copy link

andre-cgn commented Mar 20, 2021

Could you please re-open this ticket? The issue didn't magically disappear. If you don't use vue-cli but a webpack config with wp 5.27.0 and vue-loader 4.1.1 it can be re-procuded. For me it always happens when using component tag names with dashes. So using the tag name "value-input" causes the error while "valueinput" doesnt.

@m4heshd
Copy link

m4heshd commented Jun 16, 2021

@andre-cgn I've ran into this multiple times. It's just an issue with HMR. Just rebuild and run your application. It should be fine.

@barayuda
Copy link

barayuda commented Oct 19, 2022

same Issue here:
image

anyone have face same issue?

Version: Vue 3.2.40

@wflixu
Copy link

wflixu commented Feb 28, 2023

same Issue here: image

anyone have face same issue?

Version: Vue 3.2.40

I have the same problem

@wflixu
Copy link

wflixu commented Feb 28, 2023

same Issue here: image
anyone have face same issue?
Version: Vue 3.2.40

I have the same problem

I refactored the code and the problem was solved. It was mostly reactive usage if you have the same warn.

@fredcallaway

This comment was marked as spam.

@tylfin
Copy link

tylfin commented Aug 16, 2023

It looks like this issue is closed, but I recently ran into it with a dynamically rendered component. I found a couple of workarounds on StackOverflow, but none of those worked for me.

Eventually, I wrapped the component in a <KeepAlive> which actually made sense for what was happening in the form. Here's the snippet that worked for me:

    <KeepAlive>
      <component :is="foobar" />
    </KeepAlive>

Also noteworthy is I was only able to reproduce this in local dev mode, while others struggled to reproduce the same problem 🤷‍♂️

@github-actions github-actions bot locked and limited conversation to collaborators Sep 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants