facebook/flow · error
failed to deserialize Imports
Error message
failed to deserialize Imports
What it means
Panics when bincode fails to decode an Imports record from decompressed bytes. Imports entries live in the same heap-cache family as Exports (no file_key involved); the decode must consume the slice exactly, and any leftover/garbage from corruption or schema drift makes decode_from_slice return Err, which this expect escalates to a panic.
Source
Thrown at rust_port/crates/flow_heap_serialization/src/lib.rs:144
pub fn deserialize_exports(bytes: &[u8]) -> Arc<Exports> {
let decompressed = decompress(bytes);
let (exports, _): (Exports, _) =
bincode::serde::decode_from_slice(&decompressed, bincode::config::legacy())
.expect("failed to deserialize Exports");
Arc::new(exports)
}
pub fn serialize_imports(imports: &Imports) -> Vec<u8> {
let bytes = bincode::serde::encode_to_vec(imports, bincode::config::legacy())
.expect("failed to serialize Imports");
compress(&bytes)
}
pub fn deserialize_imports(bytes: &[u8]) -> Arc<Imports> {
let decompressed = decompress(bytes);
let (imports, _): (Imports, _) =
bincode::serde::decode_from_slice(&decompressed, bincode::config::legacy())
.expect("failed to deserialize Imports");
Arc::new(imports)
}
pub fn serialize_file_sig_with_errors(
file_sig: &FileSig,
errors: &[TolerableError<Loc>],
) -> Vec<u8> {
let bytes = bincode::serde::encode_to_vec((file_sig, errors), bincode::config::legacy())
.expect("failed to serialize FileSig with errors");
compress(&bytes)
}
pub fn deserialize_file_sig_with_errors(
file_key: &FileKey,
bytes: &[u8],
) -> (Arc<FileSig>, Arc<[TolerableError<Loc>]>) {
let decompressed = decompress(bytes);
set_file_key(file_key);View on GitHub (pinned to f88ac94bcf)
Solutions
- Delete the imports cache/saved state to force recomputation
- Version cache directories per flow build
- Ensure single-writer, atomic-write discipline for cache files
Defensive patterns
Strategy: fallback
Try / catch
match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
flow_heap_serialization::deserialize_imports(&bytes)
})) {
Ok(i) => i,
Err(_) => { invalidate_saved_state(); recompute_imports()? }
} Prevention
- Invalidate imports caches across version changes
- Write records atomically (temp + rename)
- Keep one writer per cache entry to avoid interleaved bytes
When it happens
Trigger: deserialize_imports on cache bytes that are truncated, corrupted, or written by a flow build with a different Imports layout; feeding the wrong record type's bytes.
Common situations: Saved states shared across flow versions; partial writes from killed processes; stale CI caches after toolchain changes.
Related errors
- failed to deserialize AST
- failed to deserialize Docblock
- failed to deserialize PackedALocTable
- failed to deserialize type sig Module
- failed to deserialize FileSig
AI-assisted analysis of facebook/flow@f88ac94bcf (2026-08-20).
Data as JSON: /api/errors/dbf27a288b3385ac.
Report an issue: GitHub.