Skip to content

Too long unresolved promise is tired and I gonna give up

License

Notifications You must be signed in to change notification settings

wongnai/promise-until-tired

Repository files navigation

Promise until tired

semantic-release JavaScript Style Guide ts code style: prettier License: MIT

Too long unresolved promise is tired and I gonna give up.

This is the promise with timeout.

Installation

yarn add promise-until-tired

Usage

import newPromiseUntilTired, { TiredFromWaitingPromiseResolveTooLongError } from 'promise-until-tired'

try {
    const value = await newPromiseUntilTired((resolve, reject) => {
        // logic
    }, timeout)
} catch (error) {
    if (error instanceof TiredFromWaitingPromiseResolveTooLongError) {
        // handle timeout logic
    } else {
        // handle other reject logic
    }
}