Log source file on compile timeout (#10672)

Log the file that failed to bytecode compile when encountering a timeout
for debugging #6105 better.

[sysinfo](https://lib.rs/crates/sysinfo) would give us the option to
report memory usage too, but i'm hesitant to add a dependency just for
the error path.
This commit is contained in:
konsti 2025-01-16 16:01:23 +01:00 committed by GitHub
parent b46c6db317
commit 8b1d3de4fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -48,8 +48,11 @@ pub enum CompileError {
#[source]
err: Box<Self>,
},
#[error("Bytecode timed out ({}s)", _0.as_secs_f32())]
CompileTimeout(Duration),
#[error("Bytecode timed out ({}s) compiling file: `{}`", elapsed.as_secs_f32(), source_file)]
CompileTimeout {
elapsed: Duration,
source_file: String,
},
#[error("Python startup timed out ({}s)", _0.as_secs_f32())]
StartupTimeout(Duration),
}
@ -358,7 +361,10 @@ async fn worker_main_loop(
// should ever take.
tokio::time::timeout(COMPILE_TIMEOUT, python_handle)
.await
.map_err(|_| CompileError::CompileTimeout(COMPILE_TIMEOUT))??;
.map_err(|_| CompileError::CompileTimeout {
elapsed: COMPILE_TIMEOUT,
source_file: source_file.clone(),
})??;
// This is a sanity check, if we don't get the path back something has gone wrong, e.g.
// we're not actually running a python interpreter.