Vue · VUE0019

Call onWatcherCleanup synchronously

Flags onwatchercleanup after await in Vue watch code before it leaks into runtime behavior.
VUE0019vite-doctor/vuewatcherserrorSuggestion

Run this rule

pnpm vite-doctor . --framework vue --rules vue/watch/no-onwatchercleanup-after-await

Why it matters

Effects that outlive their component create leaks and stale updates. Register cleanup where Vue or VueUse can dispose it automatically.

Remove onwatchercleanup after await, or move it to the Vue runtime/API that owns that behavior.

Example

Register watcher cleanup before await

Before

<script setup lang="ts">
watch(id, async () => {
  await loadUser()
  onWatcherCleanup(cancelLoad)
})
</script>

After

<script setup lang="ts">
watch(id, async () => {
  onWatcherCleanup(cancelLoad)
  await loadUser()
})
</script>
Copyright © 2026