Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/proc/legacy/deps.ts>abortablePromise

A high-level way to run child processes that is easy, flexible, powerful, and prevents resource leaks.
Go to Latest
function abortablePromise
import { abortablePromise } from "https://deno.land/x/proc@0.20.1/legacy/deps.ts";

Make Promise abortable with the given signal.

Examples

Example 1

import { abortablePromise } from "https://deno.land/std@0.224.0/async/mod.ts";

const request = fetch("https://example.com");

const c = new AbortController();
setTimeout(() => c.abort(), 100);

const p = abortablePromise(request, c.signal);

// The below throws if the request didn't resolve in 100ms
await p;

Parameters

p: Promise<T>
signal: AbortSignal

Returns

Promise<T>