{"record":{"id":"00d9f237f0210609","repo":"moeru-ai/airi","slug":"opfs-ziploader-not-found-in-middlewares-caching","errorCode":null,"errorMessage":"[OPFS] ZipLoader not found in middlewares, caching disabled","messagePattern":"\\[OPFS\\] ZipLoader not found in middlewares, caching disabled","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/stage-ui-live2d/src/utils/live2d-opfs-registration.ts","lineNumber":17,"sourceCode":"import { Live2DFactory, ZipLoader } from 'pixi-live2d-display/cubism4'\n\nimport { OPFSCache } from './opfs-loader'\n\nconst zipLoaderIndex = Live2DFactory.live2DModelMiddlewares.indexOf(ZipLoader.factory)\n\nif (Live2DFactory.live2DModelMiddlewares.includes(OPFSCache.checkMiddleware)) {\n  // Middlewares already registered.\n}\nelse if (zipLoaderIndex !== -1) {\n  // Insert Check before ZipLoader\n  Live2DFactory.live2DModelMiddlewares.splice(zipLoaderIndex, 0, OPFSCache.checkMiddleware)\n  // Insert Save after ZipLoader\n  Live2DFactory.live2DModelMiddlewares.splice(zipLoaderIndex + 2, 0, OPFSCache.saveMiddleware)\n}\nelse {\n  console.warn('[OPFS] ZipLoader not found in middlewares, caching disabled')\n}\n","sourceCodeStart":1,"sourceCodeEnd":19,"githubUrl":"https://github.com/moeru-ai/airi/blob/677329427f32468c74b17f3ec47eeca4e05bec65/packages/stage-ui-live2d/src/utils/live2d-opfs-registration.ts#L1-L19","documentation":"live2d-opfs-registration inserts OPFSCache.checkMiddleware before ZipLoader.factory and OPFSCache.saveMiddleware after it in Live2DFactory.live2DModelMiddlewares, so models loaded from zips get cached in OPFS. ZipLoader.factory is the anchor; if it is not present in the middleware array, there is nothing to splice around and OPFS caching is silently disabled with this warning.","triggerScenarios":"The pixi-live2d-display bundle variant loaded does not register ZipLoader (a build stripping the zip loader), or code that cleared/replaced Live2DFactory.live2DModelMiddlewares before this module evaluated.","commonSituations":"Tree-shaking or a custom cubism4 entry that omits ZipLoader; middleware arrays mutated by another integration; import-order changes after refactoring.","solutions":["Ensure the ZipLoader-enabled cubism4 entry ('pixi-live2d-display/cubism4') is imported (and its ZipLoader registered) before importing the OPFS registration module","Assert at registration time that Live2DFactory.live2DModelMiddlewares includes ZipLoader.factory, and fail loudly in dev if not","Avoid replacing the middleware array wholesale; mutate in place so the anchor stays"],"exampleFix":"// before\nimport { Live2DFactory, ZipLoader } from 'pixi-live2d-display/cubism4'\nconst idx = Live2DFactory.live2DModelMiddlewares.indexOf(ZipLoader.factory)\nif (idx === -1)\n  console.warn('[OPFS] ZipLoader not found, caching disabled')\n\n// after (make the missing anchor a dev-time failure, or register it first)\nimport { Live2DFactory, ZipLoader } from 'pixi-live2d-display/cubism4'\nlet idx = Live2DFactory.live2DModelMiddlewares.indexOf(ZipLoader.factory)\nif (idx === -1) {\n  Live2DFactory.live2DModelMiddlewares.push(ZipLoader.factory)\n  idx = Live2DFactory.live2DModelMiddlewares.length - 1\n}","handlingStrategy":"validation","validationCode":"import { Live2DFactory, ZipLoader } from 'pixi-live2d-display/cubism4'\n\nconst hasZipLoader = Live2DFactory.live2DModelMiddlewares.includes(ZipLoader.factory)\nif (!hasZipLoader) {\n  // register the anchor first, or skip OPFS registration knowingly\n  Live2DFactory.live2DModelMiddlewares.push(ZipLoader.factory)\n}","typeGuard":"function hasZipLoaderMiddleware(middlewares: Array<unknown>): boolean {\n  return middlewares.includes(ZipLoader.factory)\n}","tryCatchPattern":null,"preventionTips":["Import the zip-capable cubism4 entry before any OPFS registration module side effect","Never replace Live2DFactory.live2DModelMiddlewares with a new array; splice in place","Add a dev-only assertion after registration that both OPFS middlewares are present"],"tags":["live2d","opfs","middleware","caching","registration-order"],"backgroundTag":"middleware-registration-order","analyzedSha":"677329427f32468c74b17f3ec47eeca4e05bec65","analyzedAt":"2026-08-18T17:29:58.153Z","contentChangedAt":"2026-08-18T17:29:58.153Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}