question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maxmium recursive updates exceeded

See original GitHub issue

Reproduction

Repro example see master branch: https://github.com/slauzinho/pinia-bug-repro

When rendering a value returned by an action that uses another store that has already been initialised it get: Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.

Steps to reproduce the behavior

const useCounterStore = defineStore({
  id: "counterStore",
  state: () => ({
    currentValue: 0
  }),
  actions: {
    increment() {
      this.currentValue++;
    },
    decrement() {
      this.currentValue--;
    }
  }
});
const useWarningStore = defineStore({
  id: "warningStore",
  actions: {
    isBigger(value: number) {
      const counterStore = useCounterStore();
      return counterStore.currentValue > value;
    }
  }
});

My Warning Page is like this:

<template>
  <div>Is Value bigger then 4 {{ warningStore.isBigger(4) }}</div>
</template>

My homepage:

<template>
  <div>Hello from home</div>
  <div>Current count value is: {{ counterStore.currentValue }}</div>
  <div>
    <button @click="counterStore.increment">Increment</button>
    <button @click="counterStore.decrement">Decrement</button>
  </div>
  <router-link to="/warning">Go to warning screen</router-link>
</template>

On the homepage we initialise the counterStore and on the Warning page we initialise the useWarningStore.

If I go from Homepage to the Warning page I get the following warning: Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies and thus recursively triggering itself. Possible sources include component template, render function, updated hook or watcher source function.

  • If I go directly to the Warning page I don’t get an error.
  • If I initialise the useWarningStore on the homepage I don’t get the error
  • If I use computed instead of calling warningStore.isBigger(4) directly I don’t get the error (see this branch)

This seems to happen only on certain cases, for instance this example is very similar but doesn’t cause the cursive warning.

Expected behavior

No recursive issues

Actual behavior

Gives recursive warning crashing the page in production.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
posvacommented, Jun 17, 2021

yes

0reactions
slauzinhocommented, Jun 24, 2021

Awesome, thanks for your help 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

vue.js - I keep getting "maximum recursive updates ...
Uncaught (in promise) Error: Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies ...
Read more >
Maximum recursive updates exceeded in component
This is the approach i found that works, but I am getting an error in console: “Maximum recursive updates exceeded in component ....
Read more >
Maximum recursive updates exceeded in component < ...
[Vue warn]: Maximum recursive updates exceeded in component . This means you have a reactive effect that is mutating its own dependencies ......
Read more >
Error: Maximum recursive updates exceeded when trying ...
Uncaught (in promise) Error: Maximum recursive updates exceeded. This means you have a reactive effect that is mutating its own dependencies ...
Read more >
Maximum recursive updates exceeded when trying to render ...
Coding example for the question Error: Maximum recursive updates exceeded when trying to render fetched data-Vue.js.
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