Ir al contenido

Missing Cancellation Token (ARCH3024)

Esta página aún no está disponible en tu idioma.

Key typescript.async.missing-abort-signal · Severity warning · Category async

Public or long-running async operations should accept an AbortSignal parameter and propagate it to inner calls so the work can be cancelled. Without it, the operation cannot be stopped in time.

async function fetchReport(id: string): Promise<Report> {
const res = await fetch(`/api/reports/${id}`);
return res.json();
}
async function fetchReport(id: string, signal?: AbortSignal): Promise<Report> {
const res = await fetch(`/api/reports/${id}`, { signal });
return res.json();
}

Add a signal?: AbortSignal parameter to the signature and pass it through to the async APIs you call.