Gathering detailed insights and metrics for lil-http-terminator
Gathering detailed insights and metrics for lil-http-terminator
Gathering detailed insights and metrics for lil-http-terminator
Gathering detailed insights and metrics for lil-http-terminator
Zero dependencies, gracefully terminates HTTP(S) server.
npm install lil-http-terminator
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
NOASSERTION License
21 Stars
49 Commits
2 Forks
1 Branches
Updated on May 12, 2025
Latest Version
1.2.3
Package Id
lil-http-terminator@1.2.3
Unpacked Size
13.08 kB
Size
4.80 kB
File Count
5
NPM Version
6.14.16
Node Version
12.22.12
Published on
Mar 17, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Gracefully terminates HTTP(S) server.
This module was forked from the amazing http-terminator. The important changes:
http-terminator
brings in more than 20 sub-dependencies, >450 files, 2 MB total.require("lil-http-terminator")({ server });
to get a terminator object.connection:close
header.When you call server.close()
, it stops the server from accepting new connections, but it keeps the existing connections open indefinitely. This can result in your server hanging indefinitely due to keep-alive connections or because of the ongoing requests that do not produce a response. Therefore, in order to close the server, you must track creation of all connections and terminate them yourself.
lil-http-terminator
implements the logic for tracking all connections and their termination upon a timeout. lil-http-terminator
also ensures graceful communication of the server intention to shutdown to any clients that are currently receiving response from this server.
1const HttpTerminator = require("lil-http-terminator");
2
3const terminator = HttpTerminator({
4 server, // required. The node.js http server object instance
5
6 // optional
7 gracefulTerminationTimeout: 1000, // optional, how much time we give "keep-alive" connections to close before destryong them
8 maxWaitTimeout: 30000, // optional, termination will return {success:false,code:"TIMED_OUT"} if it takes longer than that
9 logger: console, // optional, default is `global.console`. If termination goes wild the module might log about it using `logger.warn()`.
10});
11
12// Do not call server.close(); Instead call this:
13const { success, code, message, error } = await terminator.terminate();
14if (!success) {
15 if (code === "TIMED_OUT") console.log(message);
16 if (code === "SERVER_ERROR") console.error(message, error);
17 if (code === "INTERNAL_ERROR") console.error(message, error);
18}
Use the terminator when node.js process is shutting down.
1const http = require("http"); 2 3const server = http.createServer(); 4 5const httpTerminator = require("lil-http-terminator")({ server }); 6 7async function shutdown(signal) { 8 console.log(`Received ${signal}. Shutting down.`) 9 const { success, code, message, error } = await httpTerminator.terminate(); 10 console.log(`HTTP server closure result: ${success} ${code} ${message} ${error || ""}`); 11 process.exit(0); 12} 13 14process.on("SIGTERM", shutdown); // used by K8s, AWS ECS, etc. 15process.on("SIGINT", shutdown); // Atom, VSCode, WebStorm or Terminal Ctrl+C
There are several alternative libraries that implement comparable functionality, e.g.
The main benefit of lil-http-terminator
is that:
{success:Boolean, code:String, message:String, error?:Error}
.{success:false,code:"TIMED_OUT"}
.connection: close
headerTo gracefully terminate a HTTP server.
We say that a service is gracefully terminated when service stops accepting new clients, but allows time to complete the existing requests.
There are several reasons to terminate services gracefully:
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More