{"record":{"id":"e5a61ee2f72f53fc","repo":"ramensoftware/windhawk","slug":"archive-is-too-large-size-bytes-the-maximum-is-max-archive","errorCode":null,"errorMessage":"archive is too large (${size} bytes; the maximum is ${MAX_ARCHIVE_BYTES})","messagePattern":"archive is too large \\((.+?) bytes; the maximum is (.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/windhawk-vscode/src/extension.ts","lineNumber":1965,"sourceCode":"// are self-describing and sort chronologically. The archive's own exportedAt is\n// core-stamped in UTC and independent of this name.\nfunction defaultBackupFileName(): string {\n\tconst now = new Date();\n\tconst p = (n: number) => String(n).padStart(2, '0');\n\treturn (\n\t\t`${now.getFullYear()}-${p(now.getMonth() + 1)}-${p(now.getDate())}-` +\n\t\t`${p(now.getHours())}h${p(now.getMinutes())}m${p(now.getSeconds())}-windhawk-backup.json`\n\t);\n}\n\n// Read a picked archive file, refusing one past the core's cap by its SIZE first:\n// the read pulls the whole document into memory, so a file that cannot be a valid\n// archive must be rejected before it is read rather than after. The message is\n// worded like the core's own rejection, and the caller's catch surfaces it.\nfunction readArchiveFile(filePath: string): string {\n\tconst { size } = fs.statSync(filePath);\n\tif (size > MAX_ARCHIVE_BYTES) {\n\t\tthrow new Error(\n\t\t\t`archive is too large (${size} bytes; the maximum is ${MAX_ARCHIVE_BYTES})`\n\t\t);\n\t}\n\treturn fs.readFileSync(filePath, 'utf8');\n}\n\n// The short architecture label Windows users recognize - the vocabulary of the\n// Settings \"System type\" and Task Manager - for each clang target triple.\n// Mirrors the core hosts' table (windhawk-core core-host/src/arch.rs). An\n// unrecognized triple is surfaced verbatim rather than hidden.\nconst archLabels: Record<string, string> = {\n\t'i686-w64-mingw32': 'x86',\n\t'x86_64-w64-mingw32': 'x64',\n\t'aarch64-w64-mingw32': 'ARM64',\n};\n\n// Rewrite a forwarded compile sub-event's compileTarget from the raw clang triple\n// the core emits to the arch label, so the webview's \"Compiling <mod> for","sourceCodeStart":1947,"sourceCodeEnd":1983,"githubUrl":"https://github.com/ramensoftware/windhawk/blob/61d99ed8e182e1af1b60109612b6763ad1b4b74e/src/windhawk-vscode/src/extension.ts#L1947-L1983","documentation":"readArchiveFile stats the file before reading it, because readFileSync pulls the whole document into memory, and rejects any file larger than MAX_ARCHIVE_BYTES before that read happens. The message mirrors the Windhawk core's own oversized-archive rejection so the caller's catch surfaces a familiar error.","triggerScenarios":"Selecting/submitting a mod archive (.whl) whose byte size exceeds MAX_ARCHIVE_BYTES — importing a mod from disk, or packing a mod whose embedded binaries/bundles grew past the limit.","commonSituations":"A mod archive accidentally contains large binaries (compiled DLLs, resources, node_modules) ballooning its size; picking the wrong file (a build artifact or backup) in the import dialog; older mods became invalid after the limit was tightened.","solutions":["Shrink the archive: remove bundled binaries, compress assets, or exclude build artifacts and repack the mod.","Verify you selected the intended .whl file and not a build output or backup.","Check the reported byte count against MAX_ARCHIVE_BYTES in extension.ts to see how far over the limit the file is.","If the mod legitimately needs the payload, split it or host the large assets separately rather than inside the archive."],"exampleFix":"// before\nconst src = readArchiveFile(selectedFile); // throws at 60 MB archive\n// after\nconst { size } = fs.statSync(selectedFile);\nif (size > MAX_ARCHIVE_BYTES) size = await shrinkArchive(selectedFile);\nconst src = readArchiveFile(selectedFile);","handlingStrategy":"validation","validationCode":"import fs from 'fs';\nconst MAX = 50 * 1024 * 1024; // keep in sync with MAX_ARCHIVE_BYTES in extension.ts\nconst { size } = fs.statSync(archivePath);\nif (size > MAX) {\n  throw new Error(`archive too large: ${size} > ${MAX}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await importMod(archivePath);\n} catch (e) {\n  if (/archive is too large/.test(e.message)) {\n    promptUserToShrinkArchive(archivePath);\n  } else { throw e; }\n}","preventionTips":["Exclude build artifacts, binaries and dependency folders from mod archives.","Check archive size with stat before submitting whenever the archive is assembled programmatically.","Re-pack compressed assets if the archive drifts close to the limit.","Keep MAX_ARCHIVE_BYTES in sync between packaging scripts and the extension."],"tags":["file-size","validation","archive","resource-limit"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"61d99ed8e182e1af1b60109612b6763ad1b4b74e","analyzedAt":"2026-09-12T14:02:41.115Z","contentChangedAt":"2026-09-12T14:02:41.115Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}