diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc index 2373bbdc7..3188d9330 100644 --- a/src/libstore/remote-store.cc +++ b/src/libstore/remote-store.cc @@ -1067,15 +1067,27 @@ void RemoteStore::ConnectionHandle::withFramedSink(std::functionto, ex); - fun(sink); - sink.flush(); + { + FramedSink sink((*this)->to, ex); + fun(sink); + sink.flush(); + } + + stderrThread.join(); + if (ex) + std::rethrow_exception(ex); } }