{"record":{"id":"e83f36b880b6b932","repo":"copy/v86","slug":"zstd-worker-aborted","errorCode":null,"errorMessage":"zstd worker aborted","messagePattern":"zstd worker aborted","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/browser/starter.js","lineNumber":712,"sourceCode":"            let wasm;\n\n            globalThis.onmessage = function(e)\n            {\n                if(!wasm)\n                {\n                    const env = Object.fromEntries([\n                        \"cpu_exception_hook\", \"run_hardware_timers\",\n                        \"cpu_event_halt\", \"microtick\", \"get_rand_int\", \"stop_idling\",\n                        \"io_port_read8\", \"io_port_read16\", \"io_port_read32\",\n                        \"io_port_write8\", \"io_port_write16\", \"io_port_write32\",\n                        \"mmap_read8\", \"mmap_read32\",\n                        \"mmap_write8\", \"mmap_write16\", \"mmap_write32\", \"mmap_write64\", \"mmap_write128\",\n                        \"codegen_finalize\",\n                        \"jit_clear_func\", \"jit_clear_all_funcs\",\n                    ].map(f => [f, () => console.error(\"zstd worker unexpectedly called \" + f)]));\n\n                    env[\"__indirect_function_table\"] = new WebAssembly.Table({ element: \"anyfunc\", initial: 1024 });\n                    env[\"abort\"] = () => { throw new Error(\"zstd worker aborted\"); };\n                    env[\"log_from_wasm\"] = env[\"console_log_from_wasm\"] = (off, len) => {\n                        console.log(read_sized_string_from_mem(wasm.exports.memory.buffer, off, len));\n                    };\n                    env[\"dbg_trace_from_wasm\"] = () => console.trace();\n\n                    wasm = new WebAssembly.Instance(new WebAssembly.Module(e.data), { \"env\": env });\n                    return;\n                }\n\n                const { src, decompressed_size, id } = e.data;\n                const exports = wasm.exports;\n\n                const zstd_context = exports[\"zstd_create_ctx\"](src.length);\n                new Uint8Array(exports.memory.buffer).set(src, exports[\"zstd_get_src_ptr\"](zstd_context));\n\n                const ptr = exports[\"zstd_read\"](zstd_context, decompressed_size);\n                const result = exports.memory.buffer.slice(ptr, ptr + decompressed_size);\n                exports[\"zstd_read_free\"](ptr, decompressed_size);","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/copy/v86/blob/180830d539dcc87db1a191febf6c914f516d102f/src/browser/starter.js#L694-L730","documentation":"The zstd decompression worker instantiates a WebAssembly module whose environment provides an 'abort' function. When the zstd WASM code calls its abort intrinsic (an internal assertion/panic), the worker surfaces it as this error, indicating decompression could not proceed.","triggerScenarios":"The zstd WASM module compiled from e.data hits an internal abort (invalid/corrupt WASM or compressed input, memory allocation failure, or unsupported operation) inside the worker started via the_worker(). Any call to the imported env.abort function throws this Error in the worker.","commonSituations":"Corrupted or truncated zstd-compressed state/ROM data being decompressed; serving a mismatched or broken v86-zstd WASM build; out-of-memory conditions in the worker during large state restores; browser lacking full WebAssembly support for the compiled features.","solutions":["Verify the zstd WASM module and the compressed input data are complete and not corrupted (re-download/serve correct files)","Check the browser supports WebAssembly and the required features; try a current browser version","Check worker memory limits — large decompressions may exceed them; reduce input size or run on a main-thread fallback if available","Inspect the console for preceding WASM messages (log_from_wasm output) to identify the underlying assertion"],"exampleFix":"worker.onmessage = e => {\n    if (e.data && e.data.type === \"error\" || workerAborted) {\n    // before: silently hang\n    // after: fall back or report\n    handleDecompressFailure(e);\n    }\n};","handlingStrategy":"try-catch","validationCode":"if (typeof WebAssembly !== \"object\") {\n    fallbackToNonZstdPath();\n}\n// validate input before posting to worker\nif (!(compressed instanceof Uint8Array) || compressed.byteLength === 0) {\n    throw new Error(\"invalid zstd input\");\n}","typeGuard":"function isZstdWorkerError(e) {\n    return e instanceof Error && e.message === \"zstd worker aborted\";\n}","tryCatchPattern":"worker.onerror = e => {\n    // 'zstd worker aborted' propagates as an worker error event\n    reportDecompressFailure(e.message || \"zstd worker aborted\");\n    restartWorkerOrFallback();\n};","preventionTips":["Serve the exact zstd WASM build matching the emulator version","Validate compressed payloads (size, checksum) before sending to the worker","Keep browser/WASM runtimes up to date","Log wasm console output (log_from_wasm) to catch the underlying assertion early"],"tags":["webassembly","zstd","decompression","worker"],"backgroundTag":"wasm-abort","analyzedSha":"180830d539dcc87db1a191febf6c914f516d102f","analyzedAt":"2026-08-31T22:39:37.599Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}