Node 22vsBun

Node 22 vs Bun for trading bots

Bun is faster on startup and smaller on deps, but ecosystem compatibility with clob-client, ethers, and ws is the deciding factor. Node 22 wins for now.

At a glance

| Axis | Node 22 | Bun | | --- | --- | --- | | Cold-start time | ~80–120ms | ~10–20ms | | npm package compat | Full (reference platform) | High but not 100% | | @polymarket/clob-client tested on | Yes | Not officially | | ethers (v6) tested on | Yes | Mostly, edge cases exist | | ws WebSocket library | Works reliably | Works, some quirks | | LTS / production ready | Yes (LTS until 2027) | Yes (Bun 1.x stable) | | Built-in TypeScript | No (needs ts-node / tsx) | Yes | | Upgrade path | Stable, incremental | Fast-moving, breaking changes possible |

Detail by axis

Cold-start time

Bun starts significantly faster than Node 22. For a simple script with a handful of imports, Bun can be 5–8x faster at startup. In interactive CLI tools or serverless environments this matters enormously.

For a trading bot that runs continuously (started once, running for hours or days), cold-start time is nearly irrelevant. You pay it once. A 100ms vs 15ms difference on a bot that runs for 12 hours is noise.

Where Bun's startup advantage does matter for trading bots: auto-restart wrappers. Predtools bots use shell scripts that restart the process after a crash. If the bot crashes and restarts 10 times in a night, Bun's faster startup means slightly less downtime between restarts. Still minor.

npm package compatibility

This is the decisive axis. Predtools bots depend on three core packages: @polymarket/clob-client, ethers, and ws.

@polymarket/clob-client is a first-party Polymarket SDK tested and distributed targeting Node.js. It uses native crypto module bindings, Buffer, and some Node-specific globals. Bun implements most of these, but Polymarket does not test against Bun and does not make compatibility guarantees.

ethers v6 works on Bun for most operations, but some edge cases around provider behavior and WebSocket transport have been reported in the Bun issue tracker. For wallet-signing use cases (which is all predtools does), it generally works — but "generally" is not the confidence level you want in production code that moves real money.

ws runs on Bun but Bun also ships its own built-in WebSocket implementation. Mixing ws (the npm package) with Bun's native WebSocket can produce surprising behavior if the library auto-detects the runtime environment.

Node 22, by contrast, is the reference platform for all three packages. If something breaks on Node 22, it is a bug in the package. If something breaks on Bun, it may be a Bun compat issue that goes unfixed for weeks.

Built-in TypeScript

Bun runs TypeScript natively without a build step. Predtools bots are plain .js files — no TypeScript — so this advantage does not apply here. If you are planning to rewrite the bots in TypeScript, Bun would simplify that workflow, but the rewrite itself is a larger project.

LTS and production readiness

Node 22 is an LTS release supported until April 2027. It has a predictable release cycle, a massive community, and years of battle-hardened use in financial applications.

Bun 1.x is stable but moves fast. Minor releases have broken API behavior in the past. For a bot you are running on real money and checking at 2am, "fast-moving" is a liability. You want boring, predictable behavior.

Performance beyond cold-start

Bun's runtime performance for CPU-bound tasks is generally faster than Node's V8. For trading bots, the bottleneck is almost never CPU — it is network round-trips to the CLOB API and WebSocket message handling. Both runtimes are more than fast enough for the throughput a single-strategy bot requires.

If you were processing millions of orderbook updates per second, the runtime performance gap might matter. At the volumes predtools bots operate, it does not.

Upgrade path

Node 22 to Node 24 is a well-understood migration. The ecosystem has gone through many such transitions. Breaking changes are documented, and package maintainers test against new LTS versions promptly.

Bun's upgrade path is faster and less predictable. The Bun team ships weekly improvements and occasionally deprecates behaviors. This is great for developer tooling but adds overhead for production systems where stability is the priority.

Which should I choose?

  • Node 22 for any predtools bot running in production with real capital. The ecosystem compatibility is guaranteed, the LTS support window is long, and there is no performance benefit meaningful enough to justify the compat risk.
  • Bun for local development scripts, one-off analysis tools, or new projects written from scratch in TypeScript where you control all dependencies and can verify compatibility before going live.
  • Do not migrate existing predtools bots to Bun without first running the full bot in dry-run mode for several days and verifying that every dependency behaves identically. The risk is asymmetric: Bun gains you essentially nothing in production, but a subtle compat bug can cause silent failures in order placement or resolution polling.
  • Revisit this decision when @polymarket/clob-client adds official Bun support. Until then, Node 22 is the correct choice for production trading bots.