{"record":{"id":"1e3d934f78daa159","repo":"mihomo-party-org/clash-party","slug":"plugin-file-too-large-1e3d93","errorCode":null,"errorMessage":"Plugin file too large","messagePattern":"Plugin file too large","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/main/resolve/plugin/index.ts","lineNumber":53,"sourceCode":"\ninterface NetOpts {\n  timeout: number\n  proxy?: { host: string; port: number }\n}\n\nasync function netOpts(item?: IPluginItem): Promise<NetOpts> {\n  const { subscriptionTimeout = 30000, pluginUseProxy: globalUseProxy = false } =\n    await getAppConfig()\n  const useProxy = typeof item?.useProxy === 'boolean' ? item.useProxy : globalUseProxy\n  if (!useProxy) return { timeout: subscriptionTimeout }\n  const { getControledMihomoConfig } = await import('../../config/controledMihomo')\n  const { 'mixed-port': port = 7890 } = await getControledMihomoConfig()\n  return { timeout: subscriptionTimeout, proxy: { host: '127.0.0.1', port } }\n}\n\nfunction readDescriptor(fileBytesB64: string): IPluginDescriptor {\n  if (Buffer.byteLength(fileBytesB64, 'base64') > MAX_PLUGIN_FILE_BYTES) {\n    throw new Error('Plugin file too large')\n  }\n  const text = Buffer.from(fileBytesB64, 'base64').toString('utf-8')\n  return parseDescriptor(text)\n}\n\n// 预览：仅解析 + 校验，返回安装确认页展示子集。不建记录、不落盘、不联网。\nexport async function previewPlugin(fileBytesB64: string): Promise<IPluginDescriptorPreview> {\n  const d = readDescriptor(fileBytesB64)\n  return {\n    name: d.provider.name,\n    icon: d.provider.icon,\n    site: d.provider.site,\n    loginUrl: d.loginUrl,\n    spec: d.spec\n  }\n}\n\n// 安装：解析 + 建 needs-login 记录（无 profileId、不联网）","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/mihomo-party-org/clash-party/blob/911e090537acdf7c50bee1c3aebecc2ef119a8b5/src/main/resolve/plugin/index.ts#L35-L71","documentation":"readDescriptor decodes a base64-encoded plugin descriptor file and refuses files larger than MAX_PLUGIN_FILE_BYTES (1 MiB). This error means the supplied plugin file's decoded size exceeds that cap. The limit protects the main process from parsing arbitrarily large descriptors.","triggerScenarios":"Calling the plugin install/preview flow (readDescriptor via its callers) with a base64 file string whose decoded byte length exceeds 1048576 — e.g. an oversized descriptor file produced by a build step or a user dropping in a wrong, bulky file.","commonSituations":"Pointing the installer at a bundled archive instead of the descriptor; a generator emitting embedded assets into the descriptor; accidentally base64-ing a binary rather than a text descriptor.","solutions":["Reduce the plugin file below 1 MiB — externalize embedded assets/data into separate files.","Verify you are passing the actual descriptor file, not a package/archive.","Check the decoded size first: Buffer.byteLength(str, 'base64') <= 1024*1024 before calling.","Regenerate the descriptor if a tool bloated it with inline content."],"exampleFix":"// before\nawait installPlugin(fs.readFileSync('my-plugin.bundle.zip').toString('base64'))\n// after\nawait installPlugin(fs.readFileSync('dist/plugin.yaml').toString('base64'))","handlingStrategy":"validation","validationCode":"const bytes = Buffer.byteLength(fileB64, 'base64')\nif (bytes > 1024 * 1024) throw new Error(`plugin file ${bytes} bytes exceeds 1MiB limit`)","typeGuard":"const isPluginFileWithinLimit = (fileB64: string): boolean =>\n  Buffer.byteLength(fileB64, 'base64') <= 1024 * 1024","tryCatchPattern":"try {\n  await installPlugin(fileB64)\n} catch (e) {\n  if (e.message === 'Plugin file too large') {\n    throw new Error('Descriptor exceeds 1MiB — externalize assets and rebuild')\n  }\n  throw e\n}","preventionTips":["Check decoded size with Buffer.byteLength(b64, 'base64') before install","Keep descriptors lean; move assets/data out of the descriptor file","Confirm you pass the descriptor, not a bundle/archive","Fail fast in build tooling if generated descriptors approach 1 MiB"],"tags":["validation","size-limit","plugin","file"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"911e090537acdf7c50bee1c3aebecc2ef119a8b5","analyzedAt":"2026-08-30T13:00:49.174Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}