vue: [Vue warn]: Error in nextTick: "RangeError: Maximum call stack size exceeded"

Version

2.5.17

Reproduction link

https://jsfiddle.net/chrisvfritz/50wL7mdz/

Steps to reproduce

The error is at that function of vue.

/**
 * Helper that recursively merges two data objects together.
 */
function mergeData (to, from) {
  if (!from) { return to }
  var key, toVal, fromVal;
  var keys = Object.keys(from);
  for (var i = 0; i < keys.length; i  ) {
    key = keys[i];
    toVal = to[key];
    fromVal = from[key];
    if (!hasOwn(to, key)) {
      set(to, key, fromVal);
    } else if (isPlainObject(toVal) && isPlainObject(fromVal)) {
      mergeData(toVal, fromVal);
    }
  }

What is expected?

It is kinda weird and I don’t know from where it comes from or why is happening. So I can’t provide a link on how to reproduce it.

What is actually happening?

Many times the app is working perfectly but few times, this error appears. And the app is broken.


Sorry for not providing a Link to minimal reproduction but I don’t even know from where this error comes from since it is not happening every time.

For more info the error is showing by using those components:

<template>
	<div class="tasks-content">
		<v-tabs class="tabs" grow hide-slider height="60px" v-model="active_tab">
			<v-tab
					centered
					v-for="tab in tabs"
					:key="tab.name"
					:href="`#${tab.name}`"
					v-model="active_tab"
			>
				{{ tab.name }}
			</v-tab>
		</v-tabs>

		<v-tabs-items v-model="active_tab">
			<v-tab-item v-for="tab of tabs" :key="tab.id" :value="tab.name">
				<v-card flat>
					<!--<component :tasks="tasks" :is="active_tab"></component>-->
				</v-card>
			</v-tab-item>
		</v-tabs-items>
	</div>
</template>

<script>
	import MyTasks from './MyTasks.vue'
	import AllTasks from './AllTasks.vue'

	export default {
		name: 'TasksContent',
		components: {
			MyTasks, AllTasks
		},

		props: {
			tasks: Array
		},

		data: () => ({
			active_tab: 'MyTasks',
			tabs: [
				{ id: 1, name: 'MyTasks' },
				{ id: 2, name: 'AllTasks' },
			]
		}),

	}
</script>

<style lang="scss" scoped>
	.tasks-content {

	}
</style>
<template>
	<div class="my-tasks">
		<div class="chips">
			<v-chip small color="orange" text-color="white">
				<v-avatar class="teal">14</v-avatar>
				All
			</v-chip>

			<v-chip small color="orange" text-color="white">
				<v-avatar class="teal">9</v-avatar>
				Completed
			</v-chip>

			<v-chip small color="orange" text-color="white">
				<v-avatar class="teal">3</v-avatar>
				Pending
			</v-chip>

			<v-chip small color="orange" text-color="white">
				<v-avatar class="teal">2</v-avatar>
				Behind
			</v-chip>
		</div>
		<div class="custom-table">
			<div class="header">
				<div class="col">Assignee</div>
				<div class="col">Project</div>
				<div class="col">Status</div>
			</div>
			<div class="body">
				<div class="row" v-for="task in tasks" :key="tasks.id">
					<div class="assignee-col">
						<v-img :src="require('@/assets/temp/user.png')" height="40" width="40" />
					</div>
					<div class="project-col">
						{{ task.description.length > 25 ? task.description.slice(0, 40) : task.description }}
					</div>
					<div class="status-col">
						{{task.status}}
					</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		name: 'MyTasks',
		props: {
			tasks: {
				type: Array,
				default: () => []
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my-tasks {
		.chips {
			padding: 20px 0;
		}
		.custom-table {
			.header {
				display: grid;
				grid-template-columns: 1fr 3fr 1fr;
				.col {
					padding: 10px;
				}
			}
			.body {
				.row {
					display: grid;
					grid-template-columns: 1fr 3fr 1fr;
					border-bottom: 1px solid gray;
					grid-gap: 5px;
					padding: 10px;
				}
			}
		}
	}
</style>

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 40 (8 by maintainers)

Most upvoted comments

I figured out if you have a view component with a name “ComponentName” and imported a component with the same name attribute this will give you this error. Just remove the name attribute in the view component 😃

This solution didn’t work for me. 😕

I think i faced that issue today while using deep watch on objects containing references to Vue objects. Changing the _traverse method to this (added the check for val._isVue)

function _traverse (val, seen) {
  var i, keys;
  var isA = Array.isArray(val);
  if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode || val._isVue) {
    return
  }
  if (val.__ob__) {
    var depId = val.__ob__.dep.id;
    if (seen.has(depId)) {
      return
    }
    seen.add(depId);
  }
  if (isA) {
    i = val.length;
    while (i--) { setTimeout(_traverse, 0, val[i], seen); } 
  } else {
    keys = Object.keys(val); 
    i = keys.length;
    while (i--) { setTimeout(_traverse, 0, val[keys[i]], seen); } 
  }
}

Fixed it for me. Might it has something to do with the val instanceof VNode in esm?

ok I edited the Vue.runtime.esm.js file as follows and it works perfectly:

function _traverse (val, seen) {
  var i, keys;
  var isA = Array.isArray(val);
  if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
    return
  }
  if (val.__ob__) {
    var depId = val.__ob__.dep.id;
    if (seen.has(depId)) {
      return
    }
    seen.add(depId);
  }
  if (isA) {
    i = val.length;
    while (i--) { setTimeout(_traverse, 0, val[i], seen); } 
  } else {
    keys = Object.keys(val); 
    i = keys.length;
    while (i--) { setTimeout(_traverse, 0, val[keys[i]], seen); } 
  }
}

so this needs to be done where this kind of code appears all-over Vue

This exact error just happened to me after updating vueUse from v.9 to v.10. in a vueJs 2.6. project.

ok I edited the Vue.runtime.esm.js file as follows and it works perfectly:

function _traverse (val, seen) {
  var i, keys;
  var isA = Array.isArray(val);
  if ((!isA && !isObject(val)) || Object.isFrozen(val) || val instanceof VNode) {
    return
  }
  if (val.__ob__) {
    var depId = val.__ob__.dep.id;
    if (seen.has(depId)) {
      return
    }
    seen.add(depId);
  }
  if (isA) {
    i = val.length;
    while (i--) { setTimeout(_traverse, 0, val[i], seen); } 
  } else {
    keys = Object.keys(val); 
    i = keys.length;
    while (i--) { setTimeout(_traverse, 0, val[keys[i]], seen); } 
  }
}

so this needs to be done where this kind of code appears all-over Vue

After modification, offline code works but what if I need updated CDN or distributed code update, any help

@LinusBorg Indeed should not happen! Happened of the context i am working in. I am using Vue with Nativescript. I wont get into details on why it was the case but i fixed it on my side by making the property where i need to store that reference to non enumerable. That way _traverse wont pick it! Now it still fill that that _traverse method is missing something to avoid circular references. You cant expect all devs to assure this will never happen.

@emahuni The case described by @dracon is working as expected: you cannot use a component with the same name as the current .vue component file because A Vue component implicitly registers itself with its given name to allow recursive components

Thank you @dracon! This error left me scratching my head for a while.

I got the same issue with a completely empty page… Have no idea what can cause this