swc-project/swc · error
Could not read byte from plugin resolver
Error message
Could not read byte from plugin resolver
What it means
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.).
Source
Thrown at crates/binding_macros/src/wasm.rs:351
for entry in entries.iter() {
let entry: Array = entry
.try_into()
.expect("Resolver object missing either key or value");
let name: String = entry
.get(0)
.as_string()
.expect("Resolver key should be a string");
let buffer = entry.get(1);
//https://github.com/rustwasm/wasm-bindgen/issues/2017#issue-573013044
//We may use https://github.com/cloudflare/serde-wasm-bindgen instead later
let data = if $crate::wasm::JsCast::is_instance_of::<Uint8Array>(&buffer) {
JsValue::from(Array::from(&buffer))
} else {
buffer
};
let bytes: Vec<u8> = $crate::wasm::serde_wasm_bindgen::from_value(data).expect("Could not read byte from plugin resolver");
// In here we 'inject' externally loaded bytes into the cache, so
// remaining plugin_runner execution path works as much as
// similar between embedded runtime.
swc_core::plugin_runner::cache::PLUGIN_MODULE_CACHE.store_once(&name, bytes);
}
}
}
let opts: $crate::wasm::Options = if opts.is_null() || opts.is_undefined() {
Default::default()
} else {
$crate::wasm::serde_wasm_bindgen::from_value(opts)?
};
let error_format = opts.experimental.error_format.unwrap_or_default();
$crate::wasm::try_with_handler_globals(
c.cm.clone(),View on GitHub (pinned to 5176682b65)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/binding_macros/src/wasm.rs:351 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/a91852891b8859fd.
Report an issue: GitHub.