This package provides a utility to augment Node.js `http.Server` instances with a `kill` method that forcibly destroys all active connections. This functionality is particularly useful in development environments or during testing where immediate server shutdown is required without waiting for connections to naturally close. The current stable version is 1.0.0, released in October 2019. Given the age of the last release and lack of further updates, it can be considered abandoned. It differentiates itself by offering a simple, direct way to manage server connections beyond the standard `server.close()` which waits for active connections to finish. Its primary use case is to ensure a clean slate for server processes, especially in automated test suites.
npm install server-with-killVerified import paths — ran on the pinned version, not inferred.
Demonstrates starting an Express server, wrapping it with `server-with-kill`'s `transform` function, and then forcibly shutting it down after a set delay, including a simulated long task.
Consider alternatives like `kill-port` for process killing, or manually managing `server.close()` with connection tracking for more controlled shutdowns if full compatibility and ongoing support are required.
Use `server.kill()` primarily in testing or development environments where data integrity of active connections is not a primary concern. In production, prefer graceful shutdowns with `server.close()` and connection draining.
Always provide a callback to `serverWithKill.kill()` and check for an `err` argument to properly log or handle any issues that arise during the forced termination process.
Ensure you pass your `http.Server` instance through the `transform` function: `const serverWithKill = transform(yourHttpServer);`
This is an expected outcome when using `server.kill()`. It signifies that the connections were indeed destroyed. It's a 'problem' for the client, not necessarily the server. Inform clients that the server might abruptly shut down, or design your architecture to handle sudden disconnections.
No dependency data recorded yet.