Skip to content

Instantly share code, notes, and snippets.

@mdashlw
Created September 15, 2023 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdashlw/03eff14c01ad8ddf2248598200186c29 to your computer and use it in GitHub Desktop.
Save mdashlw/03eff14c01ad8ddf2248598200186c29 to your computer and use it in GitHub Desktop.
`probe-image-size` with `undici`
async function fastProbe(url: string): Promise<probe.ProbeResult> {
const ac = new AbortController();
const response = await undici.request(url, {
signal: ac.signal,
reset: true,
throwOnError: true,
});
return await probe(response.body).finally(() => {
ac.abort();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment