test(backup): report a broken pipe in the dump test's docker wrapper

Under a loaded full run the wrapper around pg_dump and pg_restore crashed
with an unhandled stream error, and the dump under test reported only the
tail of that stack. The wrapper now leaves the exit code to the tool and
writes the reason to stderr.
This commit is contained in:
Marc-André Bombeck committed 2026-10-29 11:51:39 +01:00
1 parent 20585f3b3d
commit a587be009d
1 file changed
+11 -1
+11 -1
View File
@@ -93,7 +93,17 @@ env.push("-e", "PGHOST=127.0.0.1", "-e", "PGPORT=5432");
const child = spawn("docker", ["exec", ...(input ? ["-i"] : []), ...env, ${JSON.stringify(container)}, ${JSON.stringify(tool)}, ...args], {
stdio: [input ? "pipe" : "ignore", "inherit", "inherit"],
});
if (input) createReadStream(input).pipe(child.stdin);
// A docker client that exits before it has read all of the input closes the
// pipe under us; that is the tool's failure to report, not a crash of this
// wrapper, so the exit code below carries it and the reason goes to stderr.
child.on("error", (err) => {
process.stderr.write("shim: " + err.message + "\\n");
process.exit(127);
});
if (input) {
child.stdin.on("error", (err) => process.stderr.write("shim stdin: " + err.code + "\\n"));
createReadStream(input).pipe(child.stdin);
}
child.on("exit", (code, signal) => process.exit(code ?? (signal ? 1 : 0)));
`,
);