{"id":19738262,"url":"https://github.com/httptoolkit/destroyable-server","last_synced_at":"2025-10-01T15:31:09.441Z","repository":{"id":61517816,"uuid":"550886623","full_name":"httptoolkit/destroyable-server","owner":"httptoolkit","description":"A tiny Node.js module to make any net.Server force-closeable","archived":false,"fork":false,"pushed_at":"2024-04-30T08:30:53.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-12T21:42:56.198Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/httptoolkit.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-13T13:40:50.000Z","updated_at":"2024-04-30T08:30:57.000Z","dependencies_parsed_at":"2024-02-12T16:13:37.393Z","dependency_job_id":"55247c6d-4878-4fcb-a7af-9c014dbce784","html_url":"https://github.com/httptoolkit/destroyable-server","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.25,"last_synced_commit":"e756ab7b8f6de0d7a25b335f1b5d9241b3bfe692"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fdestroyable-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fdestroyable-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fdestroyable-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/httptoolkit%2Fdestroyable-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/httptoolkit","download_url":"https://codeload.github.com/httptoolkit/destroyable-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234878730,"owners_count":18900681,"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-11-12T01:13:42.021Z","updated_at":"2025-10-01T15:31:09.430Z","avatar_url":"https://github.com/httptoolkit.png","language":"TypeScript","readme":"# Destroyable-Server [![Build Status](https://github.com/httptoolkit/destroyable-server/workflows/CI/badge.svg)](https://github.com/httptoolkit/destroyable-server/actions) [![Available on NPM](https://img.shields.io/npm/v/destroyable-server.svg)](https://npmjs.com/package/destroyable-server)\n\n\u003e _Part of [HTTP Toolkit](https://httptoolkit.com/): powerful tools for building, testing \u0026 debugging HTTP(S)_\n\nA tiny Node.js module to make any server force-closeable.\n\nWithout this module, when you call `server.close()` it stops listening for new connections, but it doesn't close existing connections, which can stop your process from exiting or cause problems with starting new servers.\n\nWith this module, you can call `server.destroy()` to forcibly shut down all existing sockets in addition to closing the server, to immediately \u0026 completely (but cleanly) end all connections. Unlike `server.closeIdleConnections()` and similar, this is available on all net servers (not just HTTP) closes all connections with no possibility of race conditions as new connections appear, and provides a promise you can wait on to ensure all connection closure has fully completed before your code continues.\n\nThis works for HTTP, TLS, bare sockets, whatever. Anything that extends `net.Server` or follows its patterns should work correctly.\n\nUse it like so:\n\n```javascript\nconst net = require('net');\n\nconst { makeDestroyable } = require('destroyable-server');\n\n// Create a server somewhere:\nlet server = net.Server((socket) =\u003e { /* ... */ };\n\n// Make it destroyable:\nserver = makeDestroyable(server);\n\n// When you're done with it, destroy it:\nserver.destroy();\n```\n\nCalling `makeDestroyable` mutates the passed server slightly, to track all active connections, and add a `destroy()` method which ends them.\n\nCalling `destroy()` ends the connections and the server, and returns a promise, which resolves once that is complete.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttptoolkit%2Fdestroyable-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhttptoolkit%2Fdestroyable-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhttptoolkit%2Fdestroyable-server/lists"}