Back to all use cases
Node.jsMedia and publishing

Restarting every six hours is not a fix

A publisher's Node.js 18 API pods are OOM-killed on a schedule, heap snapshots point at closures and caches, and the runtime cannot be upgraded yet.

Challenge

A leak hidden by restarts is still a leak. Pods that are killed for exceeding their memory limit drop in-flight requests, spread load unevenly while replacements warm their caches, and page whoever is on call. The restart schedule turns into a hidden dependency that nobody wants to touch.

The obvious fixes each stall. Upgrading Node.js 18, which reached end of life on 30 April 2025 with 18.20.8 as its final release, may change how the garbage collector behaves, but it does not remove a closure that keeps a request object alive or a cache with no eviction. The team is also not ready to upgrade, so the runtime has to stay covered while the leak is found.

Heap snapshots are the right tool and a risky one in production. Writing a snapshot from a pod that is already near its limit can push it over, and a snapshot from a single moment shows what is large, not what is growing.

Environment

Node.js 18 API services in containers on Kubernetes, behind a load balancer, with a memory limit per pod. The services lean on in-process caches, long-lived closures in request handlers and a few third-party packages that register event listeners.

Monitoring shows container memory climbing in a sawtooth, but nothing in the application metrics says which allocation is responsible.

Options

Raise the memory limit. Buys a longer interval between kills and costs more per pod. The leak is still there and still grows.

Restart on a schedule. Predictable, and the pattern most teams already run. It hides the symptom and leaves the dropped requests.

Upgrade the runtime first. Worth doing on its own schedule, and it keeps the runtime supported. It does not cure a leak that lives in the application's own code.

Find and remove the leak while the runtime stays patched. Take heap snapshots from a pod taken out of rotation, compare them across the growth cycle, and trace the retained objects back to the closure or cache that holds them. This is the only option that stops the growth.

Approach

OSSeva Patch keeps the Node.js 18 runtime covered while the work goes on: patched builds, delivered as signed packages and container images, with Critical CVEs fixed within 48 hours and High within 7 days.

OSSeva Assure adds 24/7 reactive support, so the team can raise the OOM kills as an incident at any hour and work it with an OSSeva engineer. The diagnosis is ordinary Node.js work: heap snapshots taken at intervals from a pod out of rotation, compared to find the objects that keep growing and the closures, caches and listeners that retain them. The fix is made in the application's code by the team that owns it. Assure also includes Node.js version upgrade path planning for the line that comes after 18.

OSSeva Operate adds the ongoing watch: event loop and memory leak alerting, 24/7 process and cluster health monitoring, a 15-minute response for P1 incidents and a named senior Node.js engineer on the account.

What this delivers

A runtime that stays patched while the leak is diagnosed, a traced cause in place of a restart schedule, and alerting that flags the next leak before a pod is killed. OSSeva Node.js support is priced per application runtime. Book a discovery call for a quote.

Go deeper

Questions

Frequently asked questions

Book a 15-minute call

Will upgrading Node.js 18 fix a memory leak?

Only if the leak is in the runtime itself. Most production leaks are in application code, such as a cache with no eviction or a closure that holds a request, and they carry over to a newer Node.js unchanged.

Is it safe to take a heap snapshot in production?

It can be, with care. A snapshot needs memory and pauses the process while it is written, so take it from a pod removed from rotation rather than one near its limit.

How do I tell a leak from normal memory growth?

A leak keeps growing across garbage collection cycles, and the heap does not return to a baseline. Comparing snapshots from the start and end of a growth cycle shows which object types gain instances.

Does OSSeva fix the leak in our code?

No. Under Assure's 24/7 reactive support an OSSeva engineer works the incident with your team and helps read the heap snapshots. The code change is made by your team, since they own the application.

See every EOL & CVE-patching use case

All use cases
Book a call