collectBrokenExternalLinks
Validates the deduplicated external URLs over the network through a bounded concurrency pool.
A network failure, an HTTP 429 and an HTTP 5xx are retried with an exponential, jittered backoff that honors Retry-After (see ExternalLinkRetryOptions); any other status, a 404 included, is final at once. Probes of one host are also capped at CollectBrokenExternalLinksOptions.perHostConcurrency, and a probe of another host is started while one host is at its cap.
Import:
import { collectBrokenExternalLinks } from '@mnaoumov/typescript-dev-toolkit/docs-site/link-check';Signature:
function collectBrokenExternalLinks(targets: Map<string, string>, fetchUrlStatus: (url: string) => Promise<number | ExternalLinkProbeResult>, concurrency: number, options: CollectBrokenExternalLinksOptions): Promise<BrokenLink[]>Parameters:
| Parameter | Type | Description |
|---|---|---|
targets |
Map<string, string> | The unique external URL → referencing page map from collectExternalTargets. |
fetchUrlStatus |
(url: string) => Promise<number | ExternalLinkProbeResult> | Injected probe returning the HTTP status for a URL (0 for a network failure), or an ExternalLinkProbeResult that also carries the server’s Retry-After. |
concurrency |
number | The maximum number of in-flight probes. |
options |
CollectBrokenExternalLinksOptions | The per-host cap and the retry policy. |
Returns: Promise<BrokenLink[]> — Every external URL that did not return HTTP 200, in the map’s iteration order.
Links to this page: