lil-http-terminator is a minimalistic, zero-dependency Node.js library designed for gracefully shutting down HTTP and HTTPS servers. Currently at stable version 1.2.3, it offers a consistent, promise-based API for managing server connections during shutdown. Its core differentiator lies in its low footprint (11 KB), absence of external dependencies, and a design that prioritizes robustness: it never throws exceptions during termination, instead resolving with a `{success, code, message, error}` object. Unlike some alternatives, it guarantees termination by timing out if connections linger, and it avoids monkey-patching Node.js core APIs. The library is actively maintained, with recent updates ensuring compatibility with newer Node.js features like `server.closeIdleConnections()`.
npm install lil-http-terminatorVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a basic HTTP server and integrate `lil-http-terminator` for graceful shutdown upon receiving SIGTERM or SIGINT signals, logging the termination result.
Upgrade your Node.js runtime to version 12 or newer. For projects requiring older Node.js versions, use `lil-http-terminator@1.2.2`.
Update your error handling logic. Instead of using `try/catch` blocks around `await terminator.terminate()`, inspect the `success` and `code` properties of the resolved object. Example: `const { success, code, message } = await terminator.terminate(); if (!success) console.error(message);`Always use `await httpTerminator.terminate()` instead of `server.close()` when you need to shut down your server gracefully to ensure all connections are properly closed or destroyed.
If using ESM, change `import { createHttpTerminator } from 'lil-http-terminator';` to `import createHttpTerminator from 'lil-http-terminator';`Call the `createHttpTerminator` function directly without `new`: `const terminator = createHttpTerminator({ server });`Run `npm install lil-http-terminator` or `yarn add lil-http-terminator` to install the package. Verify the import statement is `require('lil-http-terminator')` or `import createHttpTerminator from 'lil-http-terminator'`.No dependency data recorded yet.