Skip to content

Commit 2514d74

Browse files
committed
Don't drop tokio runtime
1 parent 9ea3b4a commit 2514d74

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

  • crates/vite_task_bin/tests/e2e_snapshots

crates/vite_task_bin/tests/e2e_snapshots/main.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ mod redact;
33
use std::{
44
env::{self, join_paths, split_paths},
55
ffi::OsStr,
6+
mem::ManuallyDrop,
67
path::{Path, PathBuf},
78
process::Stdio,
89
sync::Arc,
@@ -130,9 +131,6 @@ async fn run_interactive_step(
130131
let mut session = expectrl::session::Session::spawn(command)
131132
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
132133

133-
// Set a timeout for expect operations (8 seconds to leave buffer for outer timeout)
134-
session.set_expect_timeout(Some(std::time::Duration::from_secs(8)));
135-
136134
let mut output = String::new();
137135
let write_stdin_pattern = expectrl::Regex(r"\[write-stdin:([^\]]*)\]");
138136

@@ -157,8 +155,6 @@ async fn run_interactive_step(
157155
.unwrap_or_default();
158156

159157
if content.is_empty() {
160-
// Small delay to let the PTY process any pending data before EOF
161-
std::thread::sleep(std::time::Duration::from_millis(50));
162158
// EOF signal - send Ctrl-D (EOF character) to close stdin
163159
session
164160
.send(&[4]) // ASCII 4 = Ctrl-D = EOF
@@ -494,7 +490,9 @@ fn main() {
494490
let tests_dir = std::env::current_dir().unwrap().join("tests");
495491

496492
// Create tokio runtime for async operations
497-
let runtime = tokio::runtime::Runtime::new().unwrap();
493+
// tokio Runtime's drop blocks until all spawned steps complete. It could lead to infinite wait if some step hangs.
494+
// So we use `ManuallyDrop` here to avoid the drop (the process will exit anyway).
495+
let runtime = ManuallyDrop::new(tokio::runtime::Runtime::new().unwrap());
498496

499497
insta::glob!(tests_dir, "e2e_snapshots/fixtures/*", |case_path| {
500498
run_case(&runtime, &tmp_dir_path, case_path, filter.as_deref())

0 commit comments

Comments
 (0)