{"record":{"id":"392297db1aa84f1b","repo":"swc-project/swc","slug":"plugin-proxy-does-not-work-without-serialization-s","errorCode":null,"errorMessage":"Plugin proxy does not work without serialization support","messagePattern":"Plugin proxy does not work without serialization support","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/swc_plugin_proxy/src/memory_interop/read_returned_result_from_host.rs","lineNumber":26,"sourceCode":"#[cfg(target_arch = \"wasm32\")]\n// `__free` is linked from `swc_core::plugin::memory`, which re-exports the\n// allocator shim from `swc_plugin::allocation`. It must stay a linked plugin\n// symbol instead of being modeled as an `env` host import.\nextern \"C\" {\n    fn __free(ptr: *mut u8, size: i32) -> i32;\n}\n#[cfg(target_arch = \"wasm32\")]\nimpl Drop for AllocatedBytesPtr {\n    fn drop(&mut self) {\n        unsafe {\n            __free(self.0 as _, self.1 as _);\n        }\n    }\n}\n\n#[cfg(not(feature = \"encoding-impl\"))]\nfn read_returned_result_from_host_inner<F>(f: F) -> Option<AllocatedBytesPtr> {\n    unimplemented!(\"Plugin proxy does not work without serialization support\")\n}\n\n/// Performs an interop while calling host fn to get non-determined size return\n/// values from the host. This is based on the contract between host's imported\n/// fn, by imported fn allocated memory for the guest space then hand over its\n/// ptr and length via a struct. Refer plugin_runner/imported_fn/mod.rs for the\n/// detail.\n///\n/// Returns a struct AllocatedBytesPtr to the ptr for actual return value if\n/// host fn allocated return value, None otherwise.\n#[cfg(all(\n    feature = \"encoding-impl\",\n    feature = \"__plugin_mode\",\n    target_arch = \"wasm32\"\n))]\n#[cfg_attr(debug_assertions, tracing::instrument(level = \"info\", skip_all))]\nfn read_returned_result_from_host_inner<F>(f: F) -> Option<AllocatedBytesPtr>\nwhere","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_plugin_proxy/src/memory_interop/read_returned_result_from_host.rs#L8-L44","documentation":"swc_plugin_proxy is the guest (in-plugin) half of SWC's wasm plugin interop, and memory_interop/read_returned_result_from_host.rs contains the helpers that copy host-returned bytes out of guest memory. The real implementation requires the serialization protocol compiled in via the encoding-impl feature (cbor4ii + swc_common/encoding-impl); without it, read_returned_result_from_host_inner is compiled as a stub that panics with unimplemented!(\"Plugin proxy does not work without serialization support\") so a mis-featured build fails loudly instead of reading uninitialized guest memory.","triggerScenarios":"Compiling swc_plugin_proxy without the encoding-impl feature (default-features = false, or a dependency graph that only enables __plugin_mode without plugin-rt/plugin-mode) and then reaching any host-interop read path that calls read_returned_result_from_host_inner inside a plugin.","commonSituations":"Embedding swc plugin crates in a larger workspace where another dependency pins swc_plugin_proxy with default features off; feature-name drift across swc versions; hand-rolled feature sets that enable __plugin_mode directly instead of the bundling features.","solutions":["Enable the serialization feature: swc_plugin_proxy = { features = [\"plugin-rt\"] } (plugin-rt/plugin-mode both imply encoding-impl), or depend on swc_plugin_runner with its encoding-impl feature.","Verify feature resolution with `cargo tree -e features -i swc_plugin_proxy` and confirm the encoding-impl edge appears.","If this is a host-side build that should never execute plugin-proxy interop, remove or cfg-gate the code path constructing/calling the proxy."],"exampleFix":"# before\n[dependencies]\nswc_plugin_proxy = { version = \"30\", default-features = false }\n\n# after: plugin-rt implies encoding-impl\n[dependencies]\nswc_plugin_proxy = { version = \"30\", features = [\"plugin-rt\"] }","handlingStrategy":"validation","validationCode":"# verify serialization support is compiled in before running plugin code\ncargo tree -e features -i swc_plugin_proxy | grep -E 'encoding-impl|plugin-rt|plugin-mode' \\\n  || echo 'swc_plugin_proxy built WITHOUT serialization support — interop calls will panic'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never set default-features = false on swc_plugin_proxy without enabling plugin-rt/plugin-mode","Depend on swc_plugin_runner (which wires plugin-rt) rather than enabling internal __-prefixed features directly","Add a cargo tree feature check for plugin crates to CI"],"tags":["feature-flag","wasm-plugin","serialization","swc-plugin-proxy","build-config"],"backgroundTag":"missing-feature-flag","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}