MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / withTimeoutAndAbort

Function withTimeoutAndAbort

services/cloud-agent-next/wrapper/src/utils.ts:300–324  ·  view source on GitHub ↗
(
  promise: Promise<T>,
  opts: TimeoutAbortOptions
)

Source from the content-addressed store, hash-verified

298 resetInactivityTimer();
299 if (opts?.hardTimeoutMs !== undefined) {
300 hardTimeoutTimer = setTimeout(() => terminate('hard_timeout'), opts.hardTimeoutMs);
301 }
302
303 if (opts?.rawOutput) {
304 const captureBytes = (stream: ProcessOutputStream, bytes: Buffer): void => {
305 const available = Math.max(0, maxOutputBytes - rawLengths[stream]);
306 const retained = Math.min(available, bytes.length);
307 if (retained > 0) {
308 rawChunks[stream].push(Buffer.from(bytes.subarray(0, retained)));
309 rawLengths[stream] += retained;
310 }
311 if (retained < bytes.length) {
312 if (stream === 'stdout') stdoutTruncated = true;
313 else stderrTruncated = true;
314 }
315 resetInactivityTimer();
316 };
317 stdoutStream.on('data', (output: Buffer) => captureBytes('stdout', output));
318 stderrStream.on('data', (output: Buffer) => captureBytes('stderr', output));
319 } else {
320 stdoutStream.setEncoding('utf8');
321 stderrStream.setEncoding('utf8');
322 stdoutStream.on('data', (output: string) => captureOutput('stdout', output));
323 stderrStream.on('data', (output: string) => captureOutput('stderr', output));
324 }
325
326 if (opts?.signal) {
327 if (opts.signal.aborted) {

Callers 1

runAutoCommitFunction · 0.85

Calls 3

abortHandlerFunction · 0.85
rejectFunction · 0.50
addEventListenerMethod · 0.45

Tested by

no test coverage detected