INNER CODE UNIT · TypeScript

withRetries

grammyjs/grammY · src/bot.ts:637

async function withRetries<T>(
    task: () => Promise<T>,
    signal?: AbortSignal,
): Promise<T> {
    // Set up delays between retries
    const INITIAL_DELAY = 50; // ms
    let lastDelay = INITIAL_DELAY;

    // Define error handler
    /**
     * Determines the error handling strategy based on various error types.
     * Sleeps if necessary, and returns whether to retry or rethrow an error.
     */
    async function handleError(error: unknown) {
        let delay = false;
        let strategy: "retry" | "rethrow" = "rethrow";

        if (error instanceof HttpError) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…