From 534287ed65630003d731bb8e0268a6e2f7f10bd2 Mon Sep 17 00:00:00 2001 From: nibon7 Date: Mon, 25 Dec 2023 22:10:15 +0800 Subject: [PATCH] Don't create a thread if stderr_stream is None (#11421) # Description There is no need to create a thread if `stderr_stream` is `None`. --- crates/nu-protocol/src/pipeline_data.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/crates/nu-protocol/src/pipeline_data.rs b/crates/nu-protocol/src/pipeline_data.rs index 8dda06dd75..8d2e2b6d0b 100644 --- a/crates/nu-protocol/src/pipeline_data.rs +++ b/crates/nu-protocol/src/pipeline_data.rs @@ -861,10 +861,13 @@ pub fn print_if_stream( // NOTE: currently we don't need anything from stderr // so we just consume and throw away `stderr_stream` to make sure the pipe doesn't fill up - thread::Builder::new() - .name("stderr consumer".to_string()) - .spawn(move || stderr_stream.map(|x| x.into_bytes())) - .expect("could not create thread"); + if let Some(stderr_stream) = stderr_stream { + thread::Builder::new() + .name("stderr consumer".to_string()) + .spawn(move || stderr_stream.into_bytes()) + .expect("could not create thread"); + } + if let Some(stream) = stream { for s in stream { let s_live = s?;