{"id":23789941,"url":"https://github.com/blackglory/you-died","last_synced_at":"2026-04-11T04:32:45.936Z","repository":{"id":44955807,"uuid":"352334068","full_name":"BlackGlory/you-died","owner":"BlackGlory","description":"🌿 Decently exit your Node.js application when it is interrupted.","archived":false,"fork":false,"pushed_at":"2023-11-25T17:44:05.000Z","size":269,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-09T19:40:58.107Z","etag":null,"topics":["library","nodejs","npm-package","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/you-died","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/BlackGlory.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-28T13:16:26.000Z","updated_at":"2021-12-24T18:12:38.000Z","dependencies_parsed_at":"2025-02-21T12:43:09.023Z","dependency_job_id":"87b7cab6-70d1-4595-8e93-e085c25d990d","html_url":"https://github.com/BlackGlory/you-died","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/BlackGlory/you-died","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fyou-died","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fyou-died/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fyou-died/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fyou-died/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BlackGlory","download_url":"https://codeload.github.com/BlackGlory/you-died/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BlackGlory%2Fyou-died/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270065447,"owners_count":24520946,"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","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["library","nodejs","npm-package","typescript"],"created_at":"2025-01-01T17:17:44.841Z","updated_at":"2025-12-30T21:46:50.406Z","avatar_url":"https://github.com/BlackGlory.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# you-died\nDecently exit your Node.js application when it is interrupted.\n\n## Motivation\nI need to do an asynchronous cleanup action on exit, none of the modules worked for me:\n- exit-hook\n- async-exit-hook\n- death\n- node-cleanup\n\nSo I tried it myself, and finally found this:\n```ts\nprocess.once('uncaughtException', async () =\u003e {\n  await cleanup()\n\n  process.exit(0)\n})\n\nprocess.once('SIGINT', () =\u003e { throw new Error() })\n```\n\n## Install\n```sh\nnpm install --save you-died\n# or\nyarn add you-died\n```\n\n## Usage\n```ts\nimport youDied from 'you-died'\n// or whatever name you feel is decent.\n\nconst cancel1 = youDied(async () =\u003e {\n  await cleanup1()\n})\n\nconst cancel2 = youDied(async () =\u003e {\n  await cleanup2()\n})\n```\n\n## Under the hood\nThis module listens to these events:\n- `uncaughtException`\n- `SIGINT`\n- `SIGTERM`\n- `SIGBREAK`\n\nSignal event handlers will throw an error named `Signal`,\nwhich is caught by the `uncaughtException` handler.\n\n## API\n### youDied\n```ts\nfunction youDied(cleanup: () =\u003e void | PromiseLike\u003cvoid\u003e): () =\u003e void\n```\n\nYou can call this function multiple times,\nand the `cleanup` function will run sequentially.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fyou-died","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblackglory%2Fyou-died","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblackglory%2Fyou-died/lists"}