{"id":13554983,"url":"https://github.com/evinism/timebomb","last_synced_at":"2026-05-18T19:42:24.464Z","repository":{"id":52281808,"uuid":"314898698","full_name":"evinism/timebomb","owner":"evinism","description":"A cross-lang library for making sure devs get to solving old important TODOs","archived":false,"fork":false,"pushed_at":"2021-05-01T22:54:53.000Z","size":39,"stargazers_count":66,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T02:06:48.090Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evinism.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-21T20:35:24.000Z","updated_at":"2023-11-28T08:20:43.000Z","dependencies_parsed_at":"2022-09-07T04:42:12.371Z","dependency_job_id":null,"html_url":"https://github.com/evinism/timebomb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evinism%2Ftimebomb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evinism%2Ftimebomb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evinism%2Ftimebomb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evinism%2Ftimebomb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evinism","download_url":"https://codeload.github.com/evinism/timebomb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244846418,"owners_count":20520120,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:02:59.116Z","updated_at":"2026-05-18T19:42:19.436Z","avatar_url":"https://github.com/evinism.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# Timebomb\n\nTimebomb is a tiny cross-language library for failing loudly after a certain date or time has passed. \n\n* JS installation via `npm install --save timebomb-js`\n* Python installation via `pip install timebomb`\n\n## The Problem\n\nMigrations leave TODOs all over the place. After a migration is completed, these todos linger on\nfor weeks, months, and years. If only there was a way to make absolutely sure that you revisited\nthem before a certain date...\n\n## The solution\n\nFail loudly and violently if the date passes.\n\nThis comes in 3 varieties, in increasing aggressiveness:\n\n1. `warnAfter`\n2. `slowAfter`\n3. `failAfter`\n\n### warnAfter\n\nTimebomb provides the ability to throw a warning after a certain date:\n\n```ts\nimport timebomb from \"timebomb-js\";\n\nfunction foo(bar) {\n  // Temporary workaround: bar.hack() is required because of x/y/z reasons\n  timebomb.warnAfter(new Date(\"2021-10-30\"));\n  bar.hack();\n}\n```\n\n### slowAfter\n\nTimebomb provides the ability to add arbitrary latency after a certain date:\n\n```ts\nimport timebomb from \"timebomb-js\";\n\nfunction foo(bar) {\n  // Temporary workaround: bar.hack() is required because of x/y/z reasons\n  timebomb.slowAfter(new Date(\"2021-10-30\"), 100);\n  bar.hack();\n}\n```\n\nThis ensures that if some migration goes on too long, then the un-migrated code is far slower than\na refactored implementation.\n\nIf you need to force other people to move away from a deprecated method progressively, perhaps if you've got a deprecated endpoint or sdk method, you can specify a progressive latency increase. This will ensure that important requests get migrated first, followed by less important ones:\n\n```ts\nimport timebomb from \"timebomb-js\";\n\nfunction deprecatedFoo(bar) {\n  // Don't use this method after 2021-10-30, as it's being deprecated\n  timebomb.slowAfter(new Date(\"2021-10-30\"), (daysLate) =\u003e 100 * daysLate);\n  bar.doSomethingWrong();\n}\n```\n\nThis will provide a warning for a week before failing, and slow the implementation afterwards.\n\n### failAfter\n\nIf nothing else works, the most extreme option is to outright fail the request.\n\n```ts\nimport timebomb from \"timebomb-js\";\n\nfunction foo(bar) {\n  // Temporary workaround: bar.hack() is required because of x/y/z reasons\n  timebomb.failAfter(Date(\"2021-10-30\"));\n  bar.hack();\n}\n```\n\nThis will provide a warning for a week before failing, and throw an error afterwards.\n\n## `timebomb-js` Specifics\n\nThis section deals with the specifics of `timebomb-js` in Javascript\n\n### Disabling warnings / errors / slowdown in production\n\nYou can automatically disable the effects of timebomb in production by importing from `timebomb/nonprod` instead.\n\n```ts\nimport { warnAfter, slowAfter, failAfter } from \"timebomb-js/nonprod\";\n\n// Will be disabled if this code runs in production\nwarnAfter([...])\n```\n\n### Configuration\n\nEach of the functions takes an additional optional argument, called options.\n\n```ts\nwarnAfter(new Date(\"2021-10-30\"), options);\nslowAfter(new Date(\"2021-10-30\"), 200, options);\nfailAfter(new Date(\"2021-10-30\"), options);\n```\n\nOptions is an object with the following keys:\n\n| Key                 | type              | default | description                                    |\n| ------------------- | ----------------- | ------- | ---------------------------------------------- |\n| warningPeriodInDays | `number`          | 7       | How many days before expiry to warn the user   |\n| warnFunction        | `(string) =\u003e any` | builtin | What function gets called when timebomb warns? |\n| failFunction        | `(string) =\u003e any` | builtin | What function gets called when timebomb fails? |\n| shouldDisableInProd | `boolean`         | false   | Whether to disable timebomb's effects in prod  |\n| prodDetectFunction  | `() =\u003e boolean`   | builtin | How timebomb detects whether env is prod.      |\n\n### Changing configuration globally\n\nIf you want to change the behavior of timebomb globally, you can use the `updateConfig()` function provided by timebomb to update the default config.\n\n```ts\nimport { updateDefaultConfig } from \"timebomb-js\";\n\nupdateDefaultConfig({\n  warnFunction: (str: string) =\u003e reportToBackend(str) \u0026\u0026 console.warn(str),\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevinism%2Ftimebomb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevinism%2Ftimebomb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevinism%2Ftimebomb/lists"}