{"record":{"id":"a91852891b8859fd","repo":"swc-project/swc","slug":"could-not-read-byte-from-plugin-resolver","errorCode":null,"errorMessage":"Could not read byte from plugin resolver","messagePattern":"Could not read byte from plugin resolver","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/binding_macros/src/wasm.rs","lineNumber":351,"sourceCode":"                for entry in entries.iter() {\n                    let entry: Array = entry\n                        .try_into()\n                        .expect(\"Resolver object missing either key or value\");\n                    let name: String = entry\n                        .get(0)\n                        .as_string()\n                        .expect(\"Resolver key should be a string\");\n                    let buffer = entry.get(1);\n\n                    //https://github.com/rustwasm/wasm-bindgen/issues/2017#issue-573013044\n                    //We may use https://github.com/cloudflare/serde-wasm-bindgen instead later\n                    let data = if $crate::wasm::JsCast::is_instance_of::<Uint8Array>(&buffer) {\n                        JsValue::from(Array::from(&buffer))\n                    } else {\n                        buffer\n                    };\n\n                    let bytes: Vec<u8> = $crate::wasm::serde_wasm_bindgen::from_value(data).expect(\"Could not read byte from plugin resolver\");\n\n                    // In here we 'inject' externally loaded bytes into the cache, so\n                    // remaining plugin_runner execution path works as much as\n                    // similar between embedded runtime.\n                    swc_core::plugin_runner::cache::PLUGIN_MODULE_CACHE.store_once(&name, bytes);\n                }\n            }\n        }\n\n        let opts: $crate::wasm::Options = if opts.is_null() || opts.is_undefined() {\n            Default::default()\n        } else {\n          $crate::wasm::serde_wasm_bindgen::from_value(opts)?\n        };\n\n        let error_format = opts.experimental.error_format.unwrap_or_default();\n        $crate::wasm::try_with_handler_globals(\n            c.cm.clone(),","sourceCodeStart":333,"sourceCodeEnd":369,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/binding_macros/src/wasm.rs#L333-L369","documentation":"In the WASM binding's plugin resolver setup, the JS value supplied for a plugin resolver entry could not be deserialized into Vec<u8> via serde_wasm_bindgen. This fires when the entry's value is neither a Uint8Array nor a plain array of bytes — i.e. plugin_bytes_resolver_object maps a plugin name to something other than byte data (undefined, string, object, etc.).","triggerScenarios":"Thrown at crates/binding_macros/src/wasm.rs:351 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure every resolver value in plugin_bytes_resolver_object is a Uint8Array containing the plugin binary","Log the offending JS value before calling the binding to find the malformed entry","Convert in JS with new Uint8Array(...) rather than passing raw ArrayBuffer or base64 strings"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}