From 453087248ad8cf67f36757e116e913b350f5f3b2 Mon Sep 17 00:00:00 2001 From: Jonathan Turner Date: Mon, 4 May 2020 15:29:32 +1200 Subject: [PATCH] Properly drain iterating pipe so we can see errors (#1707) --- crates/nu-cli/src/commands/each.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/nu-cli/src/commands/each.rs b/crates/nu-cli/src/commands/each.rs index e916a6655d..c863367d19 100644 --- a/crates/nu-cli/src/commands/each.rs +++ b/crates/nu-cli/src/commands/each.rs @@ -82,14 +82,14 @@ fn each( match result { Ok(mut stream) => { + while let Some(result) = stream.next().await { + yield Ok(ReturnSuccess::Value(result)); + } + let errors = context.get_errors(); if let Some(error) = errors.first() { yield Err(error.clone()); } - - while let Some(result) = stream.next().await { - yield Ok(ReturnSuccess::Value(result)); - } } Err(e) => { yield Err(e);