Unverified Commit 5dc09678 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: avoid panic in module batches (#76757)

Because of eventual consistency
parent 9118a0b6
...@@ -4,7 +4,7 @@ use std::{ ...@@ -4,7 +4,7 @@ use std::{
mem::take, mem::take,
}; };
use anyhow::{bail, Result}; use anyhow::{bail, Context, Result};
use either::Either; use either::Either;
use petgraph::graph::{DiGraph, EdgeIndex, NodeIndex}; use petgraph::graph::{DiGraph, EdgeIndex, NodeIndex};
use rustc_hash::{FxHashMap, FxHashSet, FxHasher}; use rustc_hash::{FxHashMap, FxHashSet, FxHasher};
...@@ -254,7 +254,7 @@ impl PreBatches { ...@@ -254,7 +254,7 @@ impl PreBatches {
let entry_chunk_groups = chunk_group_info let entry_chunk_groups = chunk_group_info
.module_chunk_groups .module_chunk_groups
.get(&ResolvedVc::upcast(entry)) .get(&ResolvedVc::upcast(entry))
.expect("all modules need to have chunk group info"); .context("all modules need to have chunk group info")?;
let mut state = TraversalState { let mut state = TraversalState {
items: Vec::new(), items: Vec::new(),
this: self, this: self,
...@@ -279,7 +279,7 @@ impl PreBatches { ...@@ -279,7 +279,7 @@ impl PreBatches {
let chunk_groups = chunk_group_info let chunk_groups = chunk_group_info
.module_chunk_groups .module_chunk_groups
.get(&node.module) .get(&node.module)
.expect("all modules need to have chunk group info"); .context("all modules need to have chunk group info")?;
if chunk_groups != entry_chunk_groups { if chunk_groups != entry_chunk_groups {
let idx = state.this.ensure_pre_batch_for_module( let idx = state.this.ensure_pre_batch_for_module(
chunkable_module, chunkable_module,
...@@ -340,7 +340,7 @@ pub async fn compute_module_batches( ...@@ -340,7 +340,7 @@ pub async fn compute_module_batches(
let chunk_groups = chunk_group_info let chunk_groups = chunk_group_info
.module_chunk_groups .module_chunk_groups
.get(&entry) .get(&entry)
.expect("all modules need to have chunk group info"); .context("all modules need to have chunk group info")?;
pre_batches.ensure_pre_batch_for_module( pre_batches.ensure_pre_batch_for_module(
chunkable_module, chunkable_module,
chunk_groups, chunk_groups,
...@@ -608,7 +608,7 @@ pub async fn compute_module_batches( ...@@ -608,7 +608,7 @@ pub async fn compute_module_batches(
let chunk_groups = chunk_group_info let chunk_groups = chunk_group_info
.module_chunk_groups .module_chunk_groups
.get(&module) .get(&module)
.expect("all modules need to have chunk group info"); .context("all modules need to have chunk group info")?;
let key = BuildHasherDefault::<FxHasher>::default().prehash(chunk_groups.clone()); let key = BuildHasherDefault::<FxHasher>::default().prehash(chunk_groups.clone());
batch_groups batch_groups
.entry(key) .entry(key)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment