Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion builder.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export async function command(executable, args, env, timeout = 120_000) {
return stdout;
} catch (error) {
// Never include argv, environment, or stdout (which may contain credentials).
const timedOut = error.killed && error.signal === 'SIGTERM' && error.code == null;
// A deadline kill can finish with SIGPIPE while Docker shuts down.
const timedOut = error.killed && error.code == null;
const details = [timedOut ? `timed out after ${timeout / 1000}s` : 'command failed',
`exit=${error.code ?? 'none'}`, `signal=${error.signal ?? 'none'}`, `killed=${Boolean(error.killed)}`];
const operation = args.includes('version') ? 'version' : args.slice(0, 2).filter(a => /^[a-z-]+$/.test(a)).join(' ');
Expand Down
18 changes: 18 additions & 0 deletions builder.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -484,3 +484,21 @@ test('installation and CLI calls follow the selected hosted API', async t => {
assert.equal(f.calls.find(c => c.args[1] === 'status').env.VEX_API_BASE_URL, api);
}
});

test('deadline kills remain retryable when the child shuts down with SIGPIPE', { skip: process.platform === 'win32' }, async () => {
await assert.rejects(command('/bin/sh', ['-c',
"trap 'kill -PIPE $$' TERM; while :; do sleep 0.05; done"],
{}, 300), error => {
assert.match(error.message, /timed out after 0.3s/);
assert.match(error.message, /signal=SIGPIPE, killed=true/);
return true;
});
});

test('a child exiting on SIGPIPE without a deadline kill is not reported as a timeout', { skip: process.platform === 'win32' }, async () => {
await assert.rejects(command('/bin/sh', ['-c', 'kill -PIPE $$'], {}), error => {
assert.match(error.message, /command failed/);
assert.doesNotMatch(error.message, /timed out/);
return true;
});
});