Skip to content

Commit d34c891

Browse files
Copilothyf0
andcommitted
fix: drop bundler lock before awaiting coordinator in close() to prevent deadlock
Co-authored-by: hyf0 <[email protected]>
1 parent b89c4f2 commit d34c891

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

crates/rolldown_dev/src/dev_engine.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,14 @@ impl DevEngine {
362362
.map_err_to_unhandleable()
363363
.context("DevEngine: failed to send Close message to coordinator - coordinator may have already terminated")?;
364364

365-
// Close the bundler (calls `closeBundle` plugin hook)
366-
let mut bundler = self.bundler.lock().await;
367-
bundler.close().await?;
365+
// Close the bundler (calls `closeBundle` plugin hook).
366+
// The bundler lock MUST be released before waiting for the coordinator below.
367+
// Otherwise we'd deadlock: the coordinator's Close handler waits for any running
368+
// bundling task to finish, and that task may need to acquire the bundler lock.
369+
{
370+
let mut bundler = self.bundler.lock().await;
371+
bundler.close().await?;
372+
}
368373

369374
// Wait for coordinator to close (coordinator handles watcher cleanup)
370375
let coordinator_state = self.coordinator_state.lock().await;

crates/rolldown_testing/src/integration_test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,10 @@ impl IntegrationTest {
366366
// Explicitly close the dev engine to shut down the background coordinator task.
367367
// Without this, the coordinator task would persist across tests under the shared runtime.
368368
if let Err(err) = dev_engine.close().await {
369-
panic!("Failed to close dev_engine for integration test `{debug_title}`: {err:#?}");
369+
panic!(
370+
"Failed to close dev_engine for integration test in `{}` (title: `{debug_title}`): {err:#?}",
371+
test_folder_path.display()
372+
);
370373
}
371374
}
372375

0 commit comments

Comments
 (0)