
The isolated WebSocket engine built for modern Node.js 24+ runtimes. Bounded outbound memory queues, native room routing, and structured JSON wire packet enforcement without HTTP fallback bloat.
Zero socket-level memory leaks. Explicit upgrade authorizers.
1import http from "node:http";1import { subatomPulse } from "subatom-pulse";11const httpServer = http.createServer();1const io = subatomPulse({1 server: httpServer,1 path: "/ws",1 maxConnections: 10_000,1 rateLimitPerSec: 50,1 overflowPolicy: "drop-oldest",1 authenticator: async (req) => {1 const url = new URL(req.url ?? "/", "http://localhost");1 const token = url.searchParams.get("token");1 return {1 authenticated: token === "Bearer secret-app-token",1 userId: url.searchParams.get("user") ?? "guest"1 };1 }1});21io.onConnection((socket) => {1 socket.emit("system.welcome", { id: socket.id });2});31io.installSignalHandlers();1httpServer.listen(3000);
Eliminate event-loop lag caused by slow clients and unbounded socket buffers.
Every client connection operates its own independent lifecycle machine, bounded FIFO outbound buffer, and tracked event listeners[cite: 1]. Slow peers are completely isolated[cite: 1].
Microtask-scheduled queue with hard memory ceilings (maxQueueBytes) and explicit overflow policies: reject, drop-oldest, or disconnect[cite: 1, 3].
Native room routing in O(1) set complexity managed by RoomRegistry[cite: 1]. Zero memory leaks: room sets auto-prune immediately on disconnect[cite: 1].