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

P(romise) Timeout

Timeout a promise after a specified amount of time

Usage

import pTimeout from 'https://deno.land/x/p_timeout@1.0.0/mod.ts

const delayedPromise = new Promise(resolve => setTimeout(resolve, 500))

pTimeout(delayedPromise, 50).then(() => 'foo')
//=> [TimeoutError: Promise timed out after 50 milliseconds]

API

See https://doc.deno.land/https/deno.land/x/p_timeout@1.0.0/mod.ts

License/Credits