{"record":{"id":"1aacf1d4b2f59f84","repo":"swc-project/swc","slug":"failed-to-serialize-transform-result","errorCode":null,"errorMessage":"failed to serialize transform result: {}","messagePattern":"failed to serialize transform result: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/binding_macros/src/wasm.rs","lineNumber":404,"sourceCode":"                          let comments = $crate::wasm::SingleThreadedComments::default();\n                          $crate::wasm::anyhow::Context::context(\n                            c.process_js_with_custom_pass(\n                              fm,\n                              None,\n                              handler,\n                              &opts,\n                              comments,\n                              $before_pass,\n                              $after_pass,\n                          ), \"failed to process js file\"\n                          )?\n                      }\n                      Err(v) => unsafe { c.process_js(handler, $crate::wasm::serde_wasm_bindgen::from_value(v).expect(\"\"), &opts)? },\n                  };\n\n                  out\n                    .serialize($crate::wasm::compat_serializer().as_ref())\n                    .map_err(|e| $crate::wasm::anyhow::anyhow!(\"failed to serialize transform result: {}\", e))\n              })\n            },\n        )\n        .map_err(|e| $crate::wasm::convert_err(e, Some(error_format)))\n    }\n  };\n}\n\n/// Currently this relies on existence of transform_sync.\n#[macro_export]\nmacro_rules! build_transform {\n  ($(#[$m:meta])*) => {\n    build_transform!($(#[$m])*, Default::default());\n  };\n  ($(#[$m:meta])*, $opt: expr) => {\n      $(#[$m])*\n      pub fn transform(\n        s: $crate::wasm::JsValue,","sourceCodeStart":386,"sourceCodeEnd":422,"githubUrl":"https://github.com/swc-project/swc/blob/d7d74346665e36e692aa07e13d4ee3ee692ee35c/crates/binding_macros/src/wasm.rs#L386-L422","documentation":"Emitted by the build_transform_sync wasm macro (the entry point behind @swc/core's wasm transform) when the successful TransformOutput of process_js cannot be serialized to a JsValue via the compatibility serializer. Transform ran to completion; only the final boundary conversion to JS failed, which indicates an internal binding defect or wasm memory exhaustion - not bad input.","triggerScenarios":"Serializer/struct mismatches in a mis-versioned wasm build; memory pressure building the result object for very large outputs (code + sourcemap + metadata); regressions observed around binding version transitions.","commonSituations":"Large production bundles transformed in browser/wasm toolchains; after upgrading @swc/core where the wasm binary and JS glue got mixed across versions (partial install, cached artifacts).","solutions":["Clean-reinstall the wasm binding (remove node_modules/.cache and lockfile-cached artifacts) to eliminate mixed-version binaries","Transform without source maps or with smaller inputs to rule out wasm memory limits","Upgrade to the latest coherent release; these serializer failures are treated as release-blocking bugs","Report upstream with options and a size-reduced repro, including the {e} detail"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const out = transformSync(src, opts);\n} catch (e) {\n  if (String(e).startsWith('failed to serialize transform result')) {\n    // transform succeeded; only result serialization failed: retry once clean, then report\n    reportInternal(e, { swcVersion, opts });\n  }\n  throw e;\n}","preventionTips":["Clean-reinstall (remove node_modules + lockfile cache) after upgrading @swc/core to avoid mixed-version wasm binaries","Keep transform outputs and inline source maps modest in size in constrained wasm environments"],"tags":["wasm","transform","serialization","internal-error","version-skew"],"backgroundTag":null,"analyzedSha":"d7d74346665e36e692aa07e13d4ee3ee692ee35c","analyzedAt":"2026-08-16T12:41:13.160Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}