vue-async-component
defineAsyncComponent(...) without an errorComponent or onError.
Why: an async component is downloaded when it is first shown, and downloads fail: a flaky connection, or a deploy that replaced the file the old page asks for. Without an error component, Vue shows nothing in its place and the error only reaches the console. The user sees a hole in the page. Guide: Vue.
✕ Rejectedvue-async-component
vue
<script setup lang="ts">
import { defineAsyncComponent } from "vue";
const SalesChart = defineAsyncComponent(() => import("./SalesChart.vue"));
</script>
<template>
<SalesChart />
</template>✓ Accepted0 diagnostics
vue
<script setup lang="ts">
import { defineAsyncComponent } from "vue";
import LoadFailed from "./LoadFailed.vue";
const SalesChart = defineAsyncComponent({
loader: () => import("./SalesChart.vue"),
errorComponent: LoadFailed,
onError(error, retry, fail, attempts) {
if (attempts <= 3) retry();
else fail();
},
});
</script>
<template>
<SalesChart />
</template>errorComponent is shown when loading fails; onError decides whether to try again first.