diff --git a/lix/libstore/build/derivation-goal.cc b/lix/libstore/build/derivation-goal.cc index 0c7cf27b0..ca024c960 100644 --- a/lix/libstore/build/derivation-goal.cc +++ b/lix/libstore/build/derivation-goal.cc @@ -1250,6 +1250,11 @@ try { lastChildActivity = AIO().provider.getTimer().now(); if (data.empty()) { + if (!currentLogLine.empty()) { + if (flushLine() == Logger::BufferState::NeedsFlush) { + TRY_AWAIT(act->getLogger().flush()); + } + } co_return std::nullopt; } @@ -1359,11 +1364,7 @@ try { ); } - const auto r = TRY_AWAIT(handlers); - if (!currentLogLine.empty() && flushLine() == Logger::BufferState::NeedsFlush) { - TRY_AWAIT(act->getLogger().flush()); - } - co_return r; + co_return TRY_AWAIT(handlers); } catch (...) { co_return result::current_exception(); } diff --git a/tests/functional/build-hook-ca-fixed.nix b/tests/functional/build-hook-ca-fixed.nix index 0ce6d9b12..3da2de92c 100644 --- a/tests/functional/build-hook-ca-fixed.nix +++ b/tests/functional/build-hook-ca-fixed.nix @@ -36,8 +36,9 @@ let input3 = mkDerivation { shell = busybox; name = "build-remote-input-3"; + # `echo -n` tests handling of logs without trailing newlines buildCommand = '' - echo hi-input3 + echo -n hi-input3 read x < ${input2} echo $x BAZ > $out ''; diff --git a/tests/functional/build-hook.nix b/tests/functional/build-hook.nix index 99a13aee4..8f17f7033 100644 --- a/tests/functional/build-hook.nix +++ b/tests/functional/build-hook.nix @@ -39,8 +39,9 @@ let input3 = mkDerivation { shell = busybox; name = "build-remote-input-3"; + # `echo -n` tests handling of logs without trailing newlines buildCommand = '' - echo hi-input3 + echo -n hi-input3 read x < ${input2} echo $x BAZ > $out '';