npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@linn-cloud/graceful-shutdown

v1.0.0

Published

Graceful shutdown for Linn's node HTTP services: drains in-flight requests on SIGTERM instead of severing them. Published to support Linn's own consumers; intended for internal use, unsupported, and provided as-is without warranty of any kind. Proprietary

Readme

@linn-cloud/graceful-shutdown

Drains in-flight requests when a node HTTP service is told to stop, instead of severing them.

Without this, every ECS task replacement cuts whatever the service was serving and the load balancer reports it to callers as 502/504.

Use

Two calls, and the order matters.

const gracefulShutdown = require("@linn-cloud/graceful-shutdown");

// FIRST, before requiring anything heavy.
gracefulShutdown.holdSignalsUntilInstalled();

const app = require("../app");
const server = require("http").createServer(app);

server.keepAliveTimeout = 65000;
gracefulShutdown.install(server, {
  drainTimeoutMs: 20000,
  exitFlushTimeoutMs: 2000,
  log,
});
server.listen(port);

Why holdSignalsUntilInstalled() comes first

Node running as PID 1 — which is what a container ENTRYPOINT ["node", "..."] gives you — ignores SIGTERM while nothing is listening for it. It does not die; the signal is discarded and the task serves on until the platform SIGKILLs it. Loading a service's dependencies takes hundreds of milliseconds, which is a wide window to leave open, so the recorder goes above them.

The values are yours, not this package's

drainTimeoutMs must sit below your platform's own stop timeout — on ECS, the task definition's StopTimeout — with room for exitFlushTimeoutMs on top. Exceed it and the container is SIGKILLed mid-drain, severing exactly what the drain exists to protect. They are not defaulted because they are properties of a deployment.

keepAliveTimeout is likewise yours, and belongs on the server rather than here: it must exceed the load balancer's idle timeout (60s by default on an AWS ALB), or the balancer dispatches onto a socket node has just retired and reports the reset as a 502.

This does not remove the need to fix your entrypoint

If your image runs ENTRYPOINT ["npm", "run-script"], npm spawns sh -c node ..., the shell does not exec away, and node ends up a grandchild of PID 1. The signal npm forwards stops at that shell and never reaches node — so this package is inert. Run node directly:

ENTRYPOINT [ "node", "./bin/www" ]

What it does, and why it is not two lines

  • server.close() alone never finishes. It waits for every connection to end but does not retire a keep-alive connection that falls idle after the close was requested — measured on node 24 at 66s with a 65s keep-alive. The drain sweeps closeIdleConnections(); a single sweep at signal time does not help, because the connections that matter are still serving a request at that moment.
  • Responses answered during the drain are marked Connection: close, so the balancer retires the socket rather than dispatching onto one about to be destroyed.
  • process.exit() discards queued stdout. Through a real pipe with a reader that is behind, an immediate exit delivered none of 262KB — losing the one line saying how the drain ended. The exit waits for the flush, bounded.
  • Three named outcomes, not a boolean: drained, timed-out, not-running. "Nothing was listening" and "everything finished" both leave cleanly, but only one drained anything.

Notes

tsconfig.json sets "types": ["node"]. This is the first package in the workspace to touch node's own runtime — http.Server, process, signals — where the others are pure domain logic, so it is declared here rather than in tsconfig.base.json.