denoland/deno · error
invalid module type
Error message
invalid module type
What it means
In the same parse loop, after resolving a source offset to a specifier, the module must be EszipV2Module::Module to receive source bytes; hitting the catch-all arm panics "invalid module type". Well-formed writers never emit source byte sections for Redirect entries (redirects have no source), so this means the archive's sources section references a redirect module — a structural inconsistency only a corrupted or mis-generated file can contain.
Source
Thrown at libs/eszip/v2.rs:964
let wakers = {
let mut modules = modules.lock().unwrap();
let module = modules.get_mut(&specifier).expect("module not found");
match module {
EszipV2Module::Module { source, .. } => {
let slot = std::mem::replace(
source,
EszipV2SourceSlot::Ready(Arc::from(
source_bytes.into_content(),
)),
);
match slot {
EszipV2SourceSlot::Pending { wakers, .. } => wakers,
_ => panic!("already populated source slot"),
}
}
_ => panic!("invalid module type"),
}
};
for w in wakers {
w.wake();
}
}
let source_maps_len = read_u32(&mut reader).await? as usize;
let mut read = 0;
while read < source_maps_len {
let (length, specifier) = source_map_offsets
.remove(&read)
.ok_or(ParseError::InvalidV2SourceOffset(read))?;
let source_map_bytes =
Section::read_with_size(&mut reader, options, length).await?;
if !source_map_bytes.is_checksum_valid() {View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Rebuild the artifact with a current, unmodified toolchain
- Verify transport integrity (checksums, re-download) before parsing
- Isolate the failure with EszipV2::parse on the raw bytes to rule out upstream I/O corruption
- Capture the artifact and report the structural bug to the eszip maintainers
Defensive patterns
Strategy: validation
Validate before calling
// Same pre-flight: confirm magic and integrity metadata before parse. assert!(EszipV2::has_magic(&bytes[..8]), "not an eszip v2 artifact");
Prevention
- Do not post-process eszip files with external tools unless they round-trip validate
- Re-download or rebuild artifacts that fail integrity checks
- Pin one eszip version across build and runtime environments
When it happens
Trigger: Parsing an eszip v2 whose sources section contains an entry whose specifier maps to a Redirect module; files written by buggy or incompatible custom eszip producers; corruption that shifts offsets so source bytes are attributed to the wrong specifier.
Common situations: Compiled artifacts transferred without integrity checks; eszips produced by patched/forked tooling; cross-version artifact processing pipelines.
Related errors
- redirects are already resolved
- Redirects should be resolved
- missing index '{}'
- invalid utf-8 data
- Unable to parse body as form data
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/beea01a4061e4108.
Report an issue: GitHub.