anantbhandarkar/make-it-right/mir-backend-node
Claude Code and agent skill by anantbhandarkar/make-it-right
- community
- ext:[{"type":"plugin","description":"Custom plugin integration"}]
Checking that the SKILL.md file is still in the repository.
Make It Right (Node.js runtime tier). V8/Node 22–26 runtime reliability footguns that are shared across EVERY Node backend framework (Express, Fastify, NestJS, Hapi, Koa) — distinct from the generic backend gates and from any one framework's mechanics. Covers: the single-threaded event loop and what blocks it (sync I/O, huge JSON, synchronous crypto/zlib, long CPU loops, pathological regex), the absence of CPU parallelism on one process and how to get it (worker_threads / cluster), unhandled promise rejection crashes, serializing awaits in a loop vs. bounded Promise.all concurrency, stream backpressure, AbortSignal.timeout on every outbound call, uncaughtException semantics, heap limits under container memory, graceful shutdown with keep-alive sockets, async-context loss across callbacks and timers, require(esm) and native TypeScript type stripping, and npm supply-chain defaults after the 2025–2026 registry compromises. TRIGGER when the backend runtime is Node.js / V8 — sits between mir-backend (generic gates) and the framework module (e.g. mir-backend-node-express). SKIP for Python/JVM/Go/Rust/.NET/Ruby/PHP/BEAM runtimes (each has its own mir-backend-<runtime> tier), and for framework-library mechanics — Express middleware/routing goes to mir-backend-node-express, Fastify schemas/hooks to mir-backend-node-fastify, NestJS DI/guards/pipes to mir-backend-node-nestjs.
Install
npx vskill@latest install anantbhandarkar/make-it-right/mir-backend-nodeSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as anantbhandarkar/make-it-right/mir-backend-node.
/mir-backend-node · Make It Right (Node.js runtime)
The middle tier. mir-backend decides what is correct (any language). The framework module (e.g. mir-backend-node-express) knows the library's mechanics. This tier owns what's true for all Node backends because they run on V8 in a single-threaded event loop — the concurrency model and process model that Express, Fastify, NestJS, and every other Node framework all inherit.
Load order: mir-backend → mir-backend-node → <framework module>.
Runtime floor (checked against nodejs.org, 13 Aug 2026)
| Line | Status | Notes | |
|---|---|---|---|
| Node 26 | Current | latest 26.7.0; enters LTS Oct 2026. Not the production default yet. | |
| Node 24 "Krypton" | Active LTS | latest 24.19.0. The default target for new services. | |
| Node 22 "Jod" | Maintenance LTS | latest 22.23.2; EOL 2027-04-30. Acceptable floor for existing services. | |
| Node 20 "Iron" | End of life | EOL 2026-04-30. Gets no security patches. Do not target it. | |
| Node 18 | End of life | EOL 2025-04-30. |
Older versions of this skill said "Node 20+ LTS". That is now wrong — Node 20 stopped receiving security releases on 2026-04-30 and was explicitly excluded from the July 2026 security release. State Node 22 minimum, Node 24 recommended in engines.node and in the Dockerfile base image.
The Node project has announced that the odd/even release model ends with Node 27 (every line will enter LTS after its Current phase). Do not plan an upgrade path around "wait for the next even number".
Security patch floor: the 29 July 2026 release fixed 11 CVEs including two HIGH HTTP/2 issues (CVE-2026-56846 memory exhaustion, CVE-2026-56848 heap use-after-free) and a HIGH Permission Model over-grant (CVE-2026-58043). Minimum patched versions: 22.23.2 / 24.18.1 / 26.5.1.
The Node/V8 footguns AI walks into (framework-agnostic)
1. Blocking the event loop — the #1 Node reliability defect
Node is single-threaded. One synchronous operation that runs long stalls every concurrent request — latency spikes to the length of the blocking call multiplied by the backlog. AI routinely introduces blocks in hot paths:
- Synchronous filesystem calls (
fs.readFileSync,fs.writeFileSync,fs.existsSync) in request handlers → use thenode:fs/promisesasync equivalents. - `JSON.parse` / `JSON.stringify` on large payloads — these run synchronously on the V8 thread. A 5 MB JSON parse at 100 RPS is a sustained event-loop block. Stream-parse large bodies (e.g.
stream-json) or reject oversized payloads at the transport layer. - Synchronous crypto (
crypto.pbkdf2Sync,crypto.scryptSync) — use the async form (crypto.pbkdf2,crypto.scrypt) or aworker_threadspool.bcrypt.hashSyncin a route handler is the common instance of this. - Synchronous zlib (
zlib.deflateSync,zlib.gzipSync) — use stream-based zlib or the async variants. - Long CPU loops — sorting/aggregating a large in-memory dataset, deep recursive computation. Any loop that takes > 5 ms is a latency problem at scale. Offload to
worker_threads/piscina. - Pathological regex (ReDoS) — a catastrophically backtracking regex run on untrusted input blocks the loop indefinitely. Avoid nested quantifiers on unbounded user input; check with
safe-regex. This includes regexes you did not write: two 2026 CVEs inpath-to-regexp(see the Express module) are exactly this.
Rule of thumb: if it doesn't do I/O and takes more than a few milliseconds, it must not run on the event loop thread.
2. No CPU parallelism on one process
Node has no GIL, but it also has no multi-core CPU parallelism by default — async/await only concurrently waits for I/O; it does not run JavaScript in parallel. For CPU-bound work:
- `worker_threads` — V8 isolates that share memory via
SharedArrayBuffer/Atomicsor pass structured clones. Best for compute that must return a result to the main thread. Usepiscinafor a managed pool (don't spin unlimited workers). - `cluster` / multiple processes — N processes each listening on the same port. Each is an independent Node instance with its own heap. Right for scaling request handling across cores.
- Horizontal scaling — multiple container instances behind a load balancer. The canonical production answer for stateless services.
This is the runtime-level reason the runtime-map says "Do NOT use Node for heavily CPU-bound compute, data science, or heavy ML workflows."
The other pool people forget: libuv's. fs.* (async included), dns.lookup, async zlib, and async crypto do not use the event loop — they queue onto a shared libuv thread pool whose default size is 4. Four concurrent fs.readFile calls or four crypto.pbkdf2 calls starve everything else that uses it, and the symptom is identical to an event-loop block: rising latency with an idle CPU and an idle loop. Network sockets do not use this pool, so it is invisible in an HTTP-only benchmark. Raise UV_THREADPOOL_SIZE (env only, read once at startup) deliberately, and prefer dns.resolve* over dns.lookup on hot paths since only the latter is pool-bound.
3. Unhandled promise rejection crashes the process
Since Node 15 the default is --unhandled-rejections=throw: an unhandled rejection terminates the process. AI code that fires-and-forgets a promise without .catch() or await causes silent crashes in production:
Wire a global safety net — it should log + exit, not swallow:
Never set --unhandled-rejections=warn to "fix" a crash loop; it converts a loud failure into silent data loss.
Critical: `try/catch` does NOT catch errors thrown in a non-awaited promise or in a plain callback. Only the await point is guarded by a surrounding try/catch. The same holds for EventEmitter: an 'error' event with no listener throws and, on a socket or stream, takes the process down.
4. Serialized awaits in a loop — use bounded Promise.all
AI commonly writes:
Independent work should be concurrent:
But unbounded `Promise.all` over a large array exhausts the DB connection pool or the external API rate limit. Use p-limit or manual batching:
Use Promise.allSettled when partial failure is acceptable and you want all results regardless.
5. Stream backpressure — ignoring it causes OOM
stream.Writable.write() returns false when the internal buffer is full. Ignoring the return value and continuing to write() buffers data unboundedly in memory — the classic OOM pattern for large file uploads, proxies, and ETL pipelines:
stream.pipeline (and its promisified form) propagates errors and destroys every stream in the chain on failure. Always use it for stream-to-stream wiring. Pass an AbortSignal in the options so a disconnected client tears the pipeline down.
6. Timeouts on every outbound call — no timeout = hung request
Node's built-in fetch (backed by undici) has no total-request timeout. Under load, a slow or unresponsive upstream accumulates open sockets until the process runs out of file descriptors.
The current recommended pattern is AbortSignal.timeout() — not a hand-rolled AbortController + setTimeout pair:
AbortSignal.timeout rejects with a TimeoutError DOMException; distinguish it from a caller AbortError when deciding whether to retry. Undici's own headersTimeout / bodyTimeout defaults are far longer than any realistic API SLA — if you configure an undici.Agent or an axios instance, set them explicitly rather than relying on defaults.
7. uncaughtException — log and exit, never resume
process.on('uncaughtException', handler) catches synchronous throws that escape all call frames. The handler is a trap: after an uncaught exception the process heap is in an undefined state. The only safe action is to log and exit:
Do not attempt to "resume" normal operation from uncaughtException. Use a process supervisor (PM2, systemd, Kubernetes restart policy) to bring it back.
8. Heap limits under container memory constraints
Current Node does read the cgroup limit — it sizes V8's defaults from min(uv_get_total_memory(), uv_get_constrained_memory()), so the old "Node thinks it has the whole host" story is stale on Node 22/24/26. What still kills containers is the gap between the V8 old-space budget and process RSS: Buffers, native addons, Wasm, and per-thread stacks live outside old space, and every cluster worker or worker_thread gets its own heap inside the same cgroup. The kernel OOM-kills on RSS, not on old space. Set the budget explicitly so N processes fit:
Also watch --max-semi-space-size for allocation-heavy workloads. Monitor heap via process.memoryUsage() and expose it as a metric. Note that NODE_OPTIONS is honoured for these flags, which makes it both a deployment tool and a security concern (see Security).
9. Async context loss — AsyncLocalStorage for request/correlation context
Callbacks and setTimeout/setInterval fire outside the call stack where they were registered — any try/catch higher up does not cover them, and naive "thread-local" patterns break:
Use AsyncLocalStorage to carry per-request context across async boundaries:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/mir-backend-node/SKILL.md
Popularity
- Repository stars
- 15
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Extension points
pluginCustom plugin integration
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/anantbhandarkar/make-it-right/mir-backend-node)