anantbhandarkar/make-it-right/mir-backend-bun
Claude Code and agent skill by anantbhandarkar/make-it-right
- community
- ext:[{"type":"hook","description":"Pre/post lifecycle hooks"},{"type":"plugin","description":"Custom plugin integration"}]
Checking that the SKILL.md file is still in the repository.
Make It Right (Bun runtime tier). Bun 1.3 reliability footguns shared across every Bun backend (Bun.serve, Hono, Elysia, or Express under bun) - Bun is a separate runtime on JavaScriptCore, not a faster Node. Covers: Node API gaps that present as silent stubs rather than errors, caught in CI or not at all; native addons that require() cleanly then abort on first real use; Bun.serve defaults that differ from node:http (10s idleTimeout that kills SSE, development:true leaking source in 500 pages); the single-thread model and silently ignored worker_threads options; bun:test running every file in ONE process with leaking globals; the text bun.lock and the blocked-install-scripts default. Chains: mir-backend -> this -> framework module. TRIGGER when the service runs on Bun in production, or when a Node-deployed project uses bun install / bun test in CI (then only the lockfile, install-script, and test sections apply). SKIP when the production runtime is Node.js with npm/pnpm/yarn - that is mir-backend-node, which has the right lockfile, install-script, and test-runner advice. SKIP for Deno, and for mir-backend-python, -jvm, -go, -rust, -dotnet, -ruby, -php, -beam. SKIP for framework mechanics (Hono/Elysia routing, middleware order, validators) - those are mir-backend-bun-hono and sibling framework modules.
Install
npx vskill@latest install anantbhandarkar/make-it-right/mir-backend-bunSemi-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-bun.
/mir-backend-bun · Make It Right (Bun runtime)
The middle tier. mir-backend decides what is correct (any language). A framework module knows the library's mechanics. This tier owns what is true for every Bun backend because it runs on JavaScriptCore with Bun's own I/O layer and package manager — not on V8, and not on Node's standard library.
Bun is a distinct runtime that implements a large part of Node's API. It is not a Node flavour. Everything below is about the places that distinction costs you.
Load order: mir-backend → mir-backend-bun → <framework module, if any>.
Runtime state (verified 13 Aug 2026)
| Release | Status | Notes | |
|---|---|---|---|
| Bun 1.3.14 (2026-05-13) | current stable | latest on npm and the newest GitHub release. No newer release in the three months to 13 Aug 2026 | |
| Bun 1.3.13 | previous patch | the build every behaviour in this file was tested against (macOS arm64) | |
| Bun 1.3.0 (2025-10-10) | the 1.3 line | isolated installs default for workspaces, Bun.SQL, built-in Redis client, Security Scanner API, test.concurrent | |
| Bun 1.2 | superseded | switched the lockfile from binary bun.lockb to text bun.lock |
The support model is "upgrade to newest". There is no published LTS line, no end-of-life calendar, and no scheduled security-release train the way Node has. Pin an exact version in CI and your image, and own the upgrade cadence yourself.
Advisories: the GitHub Advisory Database lists one real Bun advisory, CVE-2024-21548 (medium, prototype pollution in the Bun.Glob native API, > 0.0.12, < 1.1.30) — not applicable to 1.3.x. CVE-2025-8022 was withdrawn on 2025-08-11. No open advisory affects the current line. Treat that as weaker evidence than it would be for Node: Bun does not publish a security-release feed, so "no advisory" partly reflects reporting, not just code.
Node compatibility is measured against Node v23, per Bun's own compatibility page. Bun's stated position is that a package working in Node but not in Bun is a Bun bug. That is the right policy, and it is not a plan you can ship on: the gap still exists until someone fixes it, and it will not announce itself (footgun 1).
Fitness — is Bun right for this workload?
Gate 0 uses this the same way mir-backend/references/runtime-map.md does. A mismatch is not an automatic blocker, but it must be a recorded choice, not a silent default.
| Use Bun when… | Do NOT use Bun when… | |
|---|---|---|
| HTTP/JSON services, I/O-bound APIs, WebSocket and SSE servers | You depend on native addons you have not exercised end-to-end under Bun (footgun 3) | |
| TypeScript-first services you want to run with no build step | The work is CPU-bound: compute, ML inference, large data transforms — same single-thread model as Node, and worker resourceLimits are ignored so you cannot cap a worker's heap | |
CLIs and internal tools shipped as one binary (--compile) | You need cluster handle passing, or HTTP load balancing across processes on anything other than Linux | |
Monorepo installs and CI where bun install speed is the point | Your APM/tracing agent needs ESM loader hooks — module.register is a no-op (footgun 1) | |
| Greenfield services where you control every dependency | Compliance requires a documented per-major support window and a vendor advisory feed |
The Bun footguns AI walks into (framework-agnostic)
1. Compatibility gaps are silent stubs, not errors
This is the defining Bun failure and the reason "we tested the import, it's fine" is not a test. node:module.register exists in Bun 1.3.13, is a function, accepts the call, and never runs the hook:
typeof module.register === "function" is true on both runtimes. A presence check gives you a false green. The same shape applies to Worker options (footgun 4) and to node:v8, where getHeapStatistics() returns a real object with a completely different heap_size_limit (~248 MB on Bun vs ~4.3 GB on Node for the same machine) — so any heap-headroom logic keyed off it silently changes behaviour.
Detect gaps before production, three layers:
- Run the real test suite under Bun in CI, on the same command your service runs. Not a smoke test — the suite that exercises every dependency's real code path.
- Exercise, don't import. For every native or loader-hook dependency, write a startup assertion that does the actual work (open the DB, sign the token, emit a span) and fails the build if it does not produce the expected value.
- During a migration, run both runtimes in CI on the same job matrix until Bun has been green for a full release cycle. Divergence shows up as a diff, not as a 2am page.
Read references/node-compat-gaps.md for the per-module gap table and a copy-paste startup probe.
2. The Node API gaps that change backend design
| Module | Gap | What it costs you | |
|---|---|---|---|
node:module | module.register does not run hooks; _cache/_extensions/_pathCache are no-ops | ESM loader hooks silently do nothing — OpenTelemetry auto-instrumentation, import-in-the-middle, loader-based mocking | |
node:worker_threads | Worker ignores stdin/stdout/stderr/resourceLimits/trackedUnmanagedFds | No per-worker heap cap, no captured worker output (footgun 4) | |
node:cluster | Handles and file descriptors cannot pass between workers; HTTP balancing only on Linux via SO_REUSEPORT | Multi-process scaling is Linux-only and cannot hand off sockets | |
node:inspector | Only the Profiler API | Most Node profiling and debugging tooling does not attach | |
node:https | Agent is not always used | Pooling, keep-alive, and proxy settings set on an Agent may not apply | |
node:crypto | Missing secureHeapUsed, setEngine, setFips | FIPS-mode requirements cannot be met |
Fully implemented and safe to rely on: node:fs, node:http, node:net, node:stream, node:zlib, node:dns, node:dgram, node:diagnostics_channel, node:events, node:buffer. The full per-module table is in references/node-compat-gaps.md.
`node:sqlite` does not exist in Bun. Verified on 1.3.13: require("node:sqlite") throws No such built-in module: node:sqlite. Node 22+ ships it, so ported code that uses DatabaseSync fails at import. Use bun:sqlite instead — different API, same engine.
3. Native addons: require() succeeding proves nothing
Bun implements Node-API, and most N-API addons load. The failure mode when one does not is worse than an exception. Verified on Bun 1.3.13 with better-sqlite3@13.0.3 on macOS arm64:
Node with the identical node_modules runs both fine. Two consequences:
- It is not catchable.
try/catcharound the constructor does not help; the process is gone. You cannot write a graceful fallback, only a pre-flight check. - An import-only smoke test passes. The crash needs first real use, which in a web service means the first request that touches the module — in production, under load.
Addons that link the V8 C++ API directly (NAN-era, or anything not built against Node-API) are the highest-risk class. Before Gate 5, list every transitive dependency with a .node file (find node_modules -name '*.node') and write an exercise-it assertion for each. If one cannot be exercised, that dependency is a blocker, not a risk.
4. One process, one thread — and workers that ignore your limits
Bun's model is Node's: a single-threaded event loop, no CPU parallelism in-process. The blocking rules carry over unchanged — synchronous filesystem calls, JSON.parse on a large payload, sorting a big array, and a catastrophically backtracking regex on untrusted input each stall every concurrent request for their full duration. If it does not do I/O and takes more than a few milliseconds, it must not run on the event loop thread.
Bun-specific differences:
- `bun:sqlite` is fully synchronous. Every query blocks the event loop for its duration. That is fine for a 50 µs indexed lookup and a latency incident for an unindexed scan over a large table. Index the queries or move SQLite off the request path.
- `Bun.password.hashSync` / `verifySync` block. The async forms exist; use them. Argon2id at Bun's defaults measured ~66 ms per hash — 15 logins per second per process if you make it synchronous.
- `Worker` silently ignores `resourceLimits` and `stdout`/`stderr`. Verified: with
{ stdout: true, resourceLimits: { maxOldGenerationSizeMb: 8 } }, worker output went to the parent's stdout instead ofworker.stdout(which yielded nothing), andworker.resourceLimitswasundefined(Node returns an object). You cannot cap a worker's heap. A runaway worker takes the container's memory, not its own budget. - `Bun.spawn` is the escape hatch for CPU work and for anything you need isolated. It takes an argument array and does not use a shell:
``js const proc = Bun.spawn(["./resize", inputPath], { stdout: "pipe", timeout: 30_000 }); const out = await new Response(proc.stdout).text(); ` stdout defaults to "pipe", stderr to "inherit". Pass timeout or an AbortSignal, or a wedged child holds a slot forever. proc.unref()` if the parent must be allowed to exit.
- Horizontal scaling is the production answer, same as Node.
clusteron Bun cannot pass handles and only balances on Linux.
5. Bun.serve defaults that differ from node:http
Three defaults will change your service's behaviour without appearing in any diff.
| Setting | Bun.serve default | Consequence | |
|---|---|---|---|
idleTimeout | 10 seconds | An in-flight response that sends nothing for 10 s is killed. Node's equivalent socket-inactivity setting, server.timeout, defaults to `0` — disabled, so code that ran indefinitely on Node now dies at 10 s. (Node's requestTimeout is 300 s but measures something else: time to receive the whole request, not idle time while responding) | |
development | `true` unless `NODE_ENV === "production"` | The 500 page embeds your exception message, source code, and absolute file paths | |
| bind address | all interfaces | server.hostname reports "localhost", but the socket is *:port |
The 10-second timeout kills streams. Verified: a streaming response that pauses 12 s is cut at 10 s with [Bun.serve]: request timed out after 10 seconds and the client gets a socket close. This hits SSE, long polling, large downloads on slow links, and any handler waiting on a slow query.
The development error page is an information leak. Verified on 1.3.13: with NODE_ENV unset, a thrown error produced a ~67 KB HTML response whose embedded base64 payload contained the exception message, the source of the failing file, and /private/tmp/... absolute paths. Grepping the body for the error string finds nothing, because it is base64 — a naive "we checked, it doesn't leak" test passes. Set development: false explicitly rather than relying on NODE_ENV being right in every environment.
Also: server.hostname returning "localhost" does not mean it is bound to loopback. Pass hostname: "127.0.0.1" when you mean loopback, and confirm with lsof -nP -iTCP:<port> -sTCP:LISTEN.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/mir-backend-bun/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
hookPre/post lifecycle hookspluginCustom 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-bun)