{"record":{"id":"2fd678a2e8388878","repo":"can1357/oh-my-pi","slug":"asar-member-label-has-an-inconsistent-size","errorCode":null,"errorMessage":"ASAR member '${label}' has an inconsistent size","messagePattern":"ASAR member '(.+?)' has an inconsistent size","errorType":"exception","errorClass":"ArchiveError","httpStatus":null,"severity":"error","filePath":"packages/utils/src/ar/asar.ts","lineNumber":150,"sourceCode":"\t\treturn bytes;\n\t}\n}\n\nclass UnpackedAsarMemberSource implements MemberSource {\n\treadonly #filePath?: string;\n\treadonly #size: number;\n\treadonly #integrity?: AsarIntegrity;\n\n\tconstructor(filePath: string | undefined, size: number, integrity: AsarIntegrity | undefined) {\n\t\tthis.#filePath = filePath;\n\t\tthis.#size = size;\n\t\tthis.#integrity = integrity;\n\t}\n\n\tasync read(size: number, memberPath: string): Promise<Uint8Array> {\n\t\tconst label = formatArchivePathForError(memberPath);\n\t\tif (size !== this.#size) {\n\t\t\tthrow new ArchiveError(`ASAR member '${label}' has an inconsistent size`);\n\t\t}\n\t\tif (!this.#filePath) {\n\t\t\tthrow new ArchiveError(`Archive file '${label}' is unpacked and requires a filesystem-backed ASAR archive`);\n\t\t}\n\t\tconst file = Bun.file(this.#filePath);\n\t\tconst stat = await file.stat().catch(() => {\n\t\t\tthrow new ArchiveError(`Unpacked ASAR file '${label}' was not found`);\n\t\t});\n\t\tif (stat.isDirectory()) {\n\t\t\tthrow new ArchiveError(`Unpacked ASAR file '${label}' is a directory`);\n\t\t}\n\t\tif (stat.size !== this.#size) {\n\t\t\tthrow new ArchiveError(\n\t\t\t\t`Unpacked ASAR file '${label}' size differs from its archive header (${stat.size} != ${this.#size} bytes)`,\n\t\t\t);\n\t\t}\n\t\tlet bytes: Uint8Array;\n\t\ttry {","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/utils/src/ar/asar.ts#L132-L168","documentation":"This ArchiveError is thrown by UnpackedAsarMemberSource.read when the `size` argument passed by the archive framework does not match the member size recorded in the ASAR header. It is an internal consistency check: the caller must request exactly the byte count the index declares for this file. A mismatch means either the caller passed a wrong size or the archive index was built from inconsistent metadata.","triggerScenarios":"Calling read() on an unpacked ASAR member entry with a size argument different from the entry's declared size in the ASAR JSON header (e.g. reading with a stale size after the index was re-parsed, or a framework caller computing size from the wrong entry).","commonSituations":"Bugs in code that resolves archive entries by path and passes the wrong entry's size; custom tooling that manually reads members instead of going through the archive API; corrupted or hand-edited ASAR headers.","solutions":["Ensure the size passed to read() comes from the same ArchiveIndexEntry the MemberSource was created from (entry.size), not a separately computed value","Re-read the archive index so entry metadata and member sources are in sync","Check whether custom code caches entry sizes across re-parses and clear that cache"],"exampleFix":"// before\nconst bytes = await member.read(myEstimatedSize, entry.path);\n// after\nconst bytes = await member.read(entry.size, entry.path);","handlingStrategy":"validation","validationCode":"if (requestedSize !== entry.size) throw new Error(`size mismatch for ${entry.path}: ${requestedSize} != ${entry.size}`);\nawait member.read(entry.size, entry.path);","typeGuard":"function isEntrySize(entry, size) { return size === entry.size; }","tryCatchPattern":"try { bytes = await member.read(entry.size, entry.path); } catch (e) { if (e instanceof ArchiveError && e.message.includes(\"inconsistent size\")) { /* re-read fresh index and retry */ } else throw e; }","preventionTips":["Always source the read size from the same entry object that owns the member source","Do not cache sizes separately from the archive index","Re-parse the index rather than reusing stale metadata after archive changes"],"tags":["asar","archive","consistency-check","internal-error"],"backgroundTag":"archive-member-size-mismatch","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}