MCPcopy Index your code
hub / github.com/coder/mux / createAbortController

Function createAbortController

src/node/runtime/SSHRuntime.ts:269–303  ·  view source on GitHub ↗
(
  timeoutMs: number | undefined,
  abortSignal?: AbortSignal
)

Source from the content-addressed store, hash-verified

267}
268
269function createAbortController(
270 timeoutMs: number | undefined,
271 abortSignal?: AbortSignal
272): { signal: AbortSignal; dispose: () => void; didTimeout: () => boolean } {
273 const controller = new AbortController();
274 let timedOut = false;
275
276 const onAbort = () => controller.abort();
277 if (abortSignal) {
278 if (abortSignal.aborted) {
279 controller.abort();
280 } else {
281 abortSignal.addEventListener("abort", onAbort, { once: true });
282 }
283 }
284
285 const timeoutHandle =
286 timeoutMs === undefined
287 ? undefined
288 : setTimeout(() => {
289 timedOut = true;
290 controller.abort();
291 }, timeoutMs);
292
293 return {
294 signal: controller.signal,
295 didTimeout: () => timedOut,
296 dispose: () => {
297 if (timeoutHandle) {
298 clearTimeout(timeoutHandle);
299 }
300 abortSignal?.removeEventListener("abort", onAbort);
301 },
302 };
303}
304async function waitForProcessExit(proc: ChildProcess): Promise<number> {
305 // Callers often consume stdout before awaiting the process. Tiny git helpers
306 // can close in that window, so make the helper safe even when subscribed late.

Callers 3

resolvePathMethod · 0.85

Calls 3

removeEventListenerMethod · 0.80
abortMethod · 0.65
addEventListenerMethod · 0.45

Tested by

no test coverage detected