Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

Exponential backoff middleware

If your server returns a 5xx error, it will wait 1, 2, 4, 8, 16, 32, 64, 128... seconds before retrying

Screenshot 2024-04-26 at 18.07.40.gif

Usage

import { exponentialBackoffMiddleware } from "https://esm.town/v/stevekrouse/exponentialBackoffMiddleware" export default exponentialBackoffMiddleware(() => { /* your normal http handler * / })

Example usage: https://www.val.town/v/stevekrouse/BIGweather?v=164#L114

Migrated from folder: Archive/exponentialBackoffMiddleware