hydra-eval-jobs: Fix unexpected EOF when a top-level attr fails

This commit is contained in:
Eelco Dolstra 2021-02-22 16:29:07 +01:00
parent a7d8ee98da
commit 107d60027f

View file

@ -235,12 +235,13 @@ static void worker(
else throw TypeError("attribute '%s' is %s, which is not supported", attrPath, showType(*v)); else throw TypeError("attribute '%s' is %s, which is not supported", attrPath, showType(*v));
} catch (EvalError & e) { } catch (EvalError & e) {
auto msg = e.msg();
// Transmits the error we got from the previous evaluation // Transmits the error we got from the previous evaluation
// in the JSON output. // in the JSON output.
reply["error"] = filterANSIEscapes(e.msg(), true); reply["error"] = filterANSIEscapes(msg, true);
// Don't forget to print it into the STDERR log, this is // Don't forget to print it into the STDERR log, this is
// what's shown in the Hydra UI. // what's shown in the Hydra UI.
printError("error: %s", reply["error"]); printError(msg);
} }
writeLine(to.get(), reply.dump()); writeLine(to.get(), reply.dump());
@ -326,13 +327,15 @@ int main(int argc, char * * argv)
EvalState state(myArgs.searchPath, openStore()); EvalState state(myArgs.searchPath, openStore());
Bindings & autoArgs = *myArgs.getAutoArgs(state); Bindings & autoArgs = *myArgs.getAutoArgs(state);
worker(state, autoArgs, *to, *from); worker(state, autoArgs, *to, *from);
} catch (std::exception & e) { } catch (Error & e) {
nlohmann::json err; nlohmann::json err;
err["error"] = e.what(); auto msg = e.msg();
err["error"] = filterANSIEscapes(msg, true);
printError(msg);
writeLine(to->get(), err.dump()); writeLine(to->get(), err.dump());
// Don't forget to print it into the STDERR log, this is // Don't forget to print it into the STDERR log, this is
// what's shown in the Hydra UI. // what's shown in the Hydra UI.
printError("error: %s", err["error"]); writeLine(to->get(), "restart");
} }
}, },
ProcessOptions { .allowVfork = false }); ProcessOptions { .allowVfork = false });