mihomo-party-org/clash-party · error

Plugin file too large

Error message

Plugin file too large

What it means

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.

Source

Thrown at src/main/resolve/plugin/index.ts:53

interface NetOpts {
  timeout: number
  proxy?: { host: string; port: number }
}

async function netOpts(item?: IPluginItem): Promise<NetOpts> {
  const { subscriptionTimeout = 30000, pluginUseProxy: globalUseProxy = false } =
    await getAppConfig()
  const useProxy = typeof item?.useProxy === 'boolean' ? item.useProxy : globalUseProxy
  if (!useProxy) return { timeout: subscriptionTimeout }
  const { getControledMihomoConfig } = await import('../../config/controledMihomo')
  const { 'mixed-port': port = 7890 } = await getControledMihomoConfig()
  return { timeout: subscriptionTimeout, proxy: { host: '127.0.0.1', port } }
}

function readDescriptor(fileBytesB64: string): IPluginDescriptor {
  if (Buffer.byteLength(fileBytesB64, 'base64') > MAX_PLUGIN_FILE_BYTES) {
    throw new Error('Plugin file too large')
  }
  const text = Buffer.from(fileBytesB64, 'base64').toString('utf-8')
  return parseDescriptor(text)
}

// 预览:仅解析 + 校验,返回安装确认页展示子集。不建记录、不落盘、不联网。
export async function previewPlugin(fileBytesB64: string): Promise<IPluginDescriptorPreview> {
  const d = readDescriptor(fileBytesB64)
  return {
    name: d.provider.name,
    icon: d.provider.icon,
    site: d.provider.site,
    loginUrl: d.loginUrl,
    spec: d.spec
  }
}

// 安装:解析 + 建 needs-login 记录(无 profileId、不联网)

View on GitHub (pinned to 911e090537)

Solutions

  1. Reduce the plugin file below 1 MiB — externalize embedded assets/data into separate files.
  2. Verify you are passing the actual descriptor file, not a package/archive.
  3. Check the decoded size first: Buffer.byteLength(str, 'base64') <= 1024*1024 before calling.
  4. Regenerate the descriptor if a tool bloated it with inline content.

Example fix

// before
await installPlugin(fs.readFileSync('my-plugin.bundle.zip').toString('base64'))
// after
await installPlugin(fs.readFileSync('dist/plugin.yaml').toString('base64'))
Defensive patterns

Strategy: validation

Validate before calling

const bytes = Buffer.byteLength(fileB64, 'base64')
if (bytes > 1024 * 1024) throw new Error(`plugin file ${bytes} bytes exceeds 1MiB limit`)

Type guard

const isPluginFileWithinLimit = (fileB64: string): boolean =>
  Buffer.byteLength(fileB64, 'base64') <= 1024 * 1024

Try / catch

try {
  await installPlugin(fileB64)
} catch (e) {
  if (e.message === 'Plugin file too large') {
    throw new Error('Descriptor exceeds 1MiB — externalize assets and rebuild')
  }
  throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of mihomo-party-org/clash-party@911e090537 (2026-08-30). Data as JSON: /api/errors/1e3d934f78daa159. Report an issue: GitHub.