MEM004warningPro

global-state-singleton

globalThis singleton stores mutable state that is lost on deploy/restart.

Applies to: JavaScript, TypeScript

Why this matters

Storing mutable application state (run history, counters, caches) on globalThis creates a singleton that is lost on every deploy or restart and is isolated per server instance. Use a database or external cache for state that must be durable or shared across instances.

Catch it before it ships

pip install stablestack # or: npx stablestackstablestack # scans your project, MEM004 includedstablestack explain MEM004

MEM004 is part of the Pro rule set. See pricing — the free tier ships 24 checks with no signup.

False positive in your codebase? Suppress a single line with # noqa: MEM004