{"record":{"id":"a83bab17e1f71bbe","repo":"Meituan-Dianping/mpvue","slug":"failed-to-resolve-async-component-string-factor","errorCode":null,"errorMessage":"Failed to resolve async component: ${String(factory)} (Reason: ${reason})","messagePattern":"Failed to resolve async component: (.+?) \\(Reason: (.+?)\\)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/vdom/helpers/resolve-async-component.js","lineNumber":77,"sourceCode":"\n    const forceRender = () => {\n      for (let i = 0, l = contexts.length; i < l; i++) {\n        contexts[i].$forceUpdate()\n      }\n    }\n\n    const resolve = once((res: Object | Class<Component>) => {\n      // cache resolved\n      factory.resolved = ensureCtor(res, baseCtor)\n      // invoke callbacks only if this is not a synchronous resolve\n      // (async resolves are shimmed as synchronous during SSR)\n      if (!sync) {\n        forceRender()\n      }\n    })\n\n    const reject = once(reason => {\n      process.env.NODE_ENV !== 'production' && warn(\n        `Failed to resolve async component: ${String(factory)}` +\n        (reason ? `\\nReason: ${reason}` : '')\n      )\n      if (isDef(factory.errorComp)) {\n        factory.error = true\n        forceRender()\n      }\n    })\n\n    const res = factory(resolve, reject)\n\n    if (isObject(res)) {\n      if (typeof res.then === 'function') {\n        // () => Promise\n        if (isUndef(factory.resolved)) {\n          res.then(resolve, reject)\n        }\n      } else if (isDef(res.component) && typeof res.component.then === 'function') {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/src/core/vdom/helpers/resolve-async-component.js#L59-L95","documentation":"When an async component factory's promise rejects (or its error callback fires with a reason), Vue warns that the component could not be resolved. If an error component (`errorComp`) is defined it will be rendered; otherwise the slot stays empty.","triggerScenarios":"`() => import('./Foo.vue')` failing to load (network error, 404, build chunk missing); a factory using the advanced object syntax calling `reject(reason)`; a webpack dynamic import throwing at runtime.","commonSituations":"Chunk load failures after a deploy invalidates old hashed filenames; misconfigured publicPath/code-splitting; offline PWA with stale service-worker cache; typo in the import path.","solutions":["Check the browser network/console for the failing chunk URL and fix the import path or deployment","Define `error` and `loading` components: `() => ({ component: import('./Foo.vue'), error: ErrorComp, delay: 200 })` so failures degrade gracefully","Add a retry on chunk-load error (reload the page or re-attempt the import)","Verify publicPath and service worker cache strategy after deployments"],"exampleFix":"// before\nconst Foo = () => import('./Foo.vue')\n// after\nconst Foo = () => ({\n  component: import('./Foo.vue'),\n  error: { template: '<div>Failed to load</div>' },\n  delay: 200,\n  timeout: 10000\n})","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"const Foo = () => ({\n  component: import('./Foo.vue').catch(err => {\n    console.error('chunk load failed', err)\n    // optional: window.location.reload() once to recover stale chunks\n    return Promise.reject(err)\n  }),\n  error: { template: '<div>Component failed to load. <button @click=\"$forceUpdate()\">Retry</button></div>' },\n  delay: 200,\n  timeout: 10000\n})","preventionTips":["Always provide error/loading components for async components","Set a timeout so hangs surface","Watch for chunk 404s after deployments; consider chunk-error page reloads","Keep service-worker cache strategies in sync with hashed chunk names"],"tags":["async-component","dynamic-import","code-splitting"],"backgroundTag":"async-component-load-failed","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}