chore: rebuild dist for cli-provider timeout changes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
frostebite
2026-03-05 12:55:23 +00:00
parent fe63d7b32d
commit f06f99b3e5
2 changed files with 85 additions and 6 deletions

89
dist/index.js generated vendored
View File

@@ -4952,13 +4952,58 @@ exports.TaskService = TaskService;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const child_process_1 = __nccwpck_require__(32081);
const core = __importStar(__nccwpck_require__(42186));
const orchestrator_logger_1 = __importDefault(__nccwpck_require__(32549));
const DEFAULT_TIMEOUT_MS = 300000; // 300 seconds
const RUN_TASK_TIMEOUT_MS = 7200000; // 2 hours
const WATCH_WORKFLOW_TIMEOUT_MS = 3600000; // 1 hour
const SIGKILL_GRACE_MS = 10000; // 10 seconds grace period before SIGKILL
/**
* Gracefully kill a child process: SIGTERM first, then SIGKILL after a grace period.
*/
function gracefulKill(child, graceMs = SIGKILL_GRACE_MS) {
child.kill('SIGTERM');
const forceKillTimer = setTimeout(() => {
try {
child.kill('SIGKILL');
}
catch {
// Process may already be dead
}
}, graceMs);
// Clear the force-kill timer if the process exits on its own
child.on('close', () => {
clearTimeout(forceKillTimer);
});
}
class CliProvider {
constructor(executablePath, buildParameters) {
if (!executablePath || executablePath.trim() === '') {
@@ -4997,6 +5042,7 @@ class CliProvider {
secrets,
},
};
const timeoutMs = RUN_TASK_TIMEOUT_MS;
return new Promise((resolve, reject) => {
const child = (0, child_process_1.spawn)(this.executablePath, ['run-task'], {
stdio: ['pipe', 'pipe', 'pipe'],
@@ -5005,6 +5051,16 @@ class CliProvider {
let lastJsonResponse;
const outputLines = [];
let stderrOutput = '';
let timedOut = false;
// Set up timeout to prevent indefinite hangs
const timer = setTimeout(() => {
timedOut = true;
const minutes = Math.round(timeoutMs / 60000);
const message = `CLI provider timed out after ${minutes} minutes. The external provider may be unresponsive.`;
core.error(message);
gracefulKill(child);
reject(new Error(`CliProvider run-task timed out after ${timeoutMs}ms`));
}, timeoutMs);
child.stdin.write(JSON.stringify(request));
child.stdin.end();
child.stdout.on('data', (data) => {
@@ -5041,9 +5097,15 @@ class CliProvider {
}
});
child.on('error', (error) => {
reject(new Error(`CliProvider: failed to spawn executable '${this.executablePath}': ${error.message}`));
clearTimeout(timer);
if (!timedOut) {
reject(new Error(`CliProvider: failed to spawn executable '${this.executablePath}': ${error.message}`));
}
});
child.on('close', (code) => {
clearTimeout(timer);
if (timedOut)
return;
if (lastJsonResponse) {
if (lastJsonResponse.success) {
resolve(lastJsonResponse.output || outputLines.join('\n'));
@@ -5084,6 +5146,7 @@ class CliProvider {
command: 'watch-workflow',
params: {},
};
const timeoutMs = WATCH_WORKFLOW_TIMEOUT_MS;
return new Promise((resolve, reject) => {
const child = (0, child_process_1.spawn)(this.executablePath, ['watch-workflow'], {
stdio: ['pipe', 'pipe', 'pipe'],
@@ -5091,6 +5154,16 @@ class CliProvider {
});
let lastJsonResponse;
const outputLines = [];
let timedOut = false;
// Set up timeout to prevent indefinite hangs
const timer = setTimeout(() => {
timedOut = true;
const minutes = Math.round(timeoutMs / 60000);
const message = `CLI provider timed out after ${minutes} minutes. The external provider may be unresponsive.`;
core.error(message);
gracefulKill(child);
reject(new Error(`CliProvider watch-workflow timed out after ${timeoutMs}ms`));
}, timeoutMs);
child.stdin.write(JSON.stringify(request));
child.stdin.end();
child.stdout.on('data', (data) => {
@@ -5122,9 +5195,15 @@ class CliProvider {
}
});
child.on('error', (error) => {
reject(new Error(`CliProvider: failed to spawn executable '${this.executablePath}': ${error.message}`));
clearTimeout(timer);
if (!timedOut) {
reject(new Error(`CliProvider: failed to spawn executable '${this.executablePath}': ${error.message}`));
}
});
child.on('close', (code) => {
clearTimeout(timer);
if (timedOut)
return;
if (lastJsonResponse) {
if (lastJsonResponse.success) {
resolve(lastJsonResponse.output || outputLines.join('\n'));
@@ -5144,7 +5223,7 @@ class CliProvider {
}
/**
* Execute a CLI provider subcommand with a default timeout.
* Used for all methods except runTaskInWorkflow and watchWorkflow (which have no timeout).
* Timeout applies a graceful SIGTERM followed by SIGKILL after a grace period.
*/
execute(command, params, timeoutMs = DEFAULT_TIMEOUT_MS) {
const request = { command, params };
@@ -5156,10 +5235,10 @@ class CliProvider {
let stdoutData = '';
let stderrData = '';
let timedOut = false;
// Set up timeout
// Set up timeout with graceful kill
const timer = setTimeout(() => {
timedOut = true;
child.kill('SIGTERM');
gracefulKill(child);
reject(new Error(`CliProvider: command '${command}' timed out after ${timeoutMs}ms`));
}, timeoutMs);
child.stdin.write(JSON.stringify(request));

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long