npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

logboat

v0.1.0

Published

A small, pragmatic raft: single-term leader, static membership, pluggable log storage (including a low-write-amplification segment WAL for consumer SSDs) and pluggable transport.

Downloads

21

Readme

logboat

A small, pragmatic raft for Node.js — built to run real replicated state machines on modest hardware, and to be embedded rather than deployed.

logboat was extracted from a working sharded transaction system where it replicates state machines at thousands of commits per second on consumer NVMe drives. Its design bias is operational honesty over feature count: a small surface you can read in an afternoon, storage engineered for the write patterns raft actually produces, and deliberate scope limits documented up front.

What you get

  • RaftNode — the consensus core. Byte-payload proposals (propose(Buffer)), an ordered apply loop, snapshot/restore callbacks, leadership notifications, and per-peer replication with fast conflict backoff.
  • Catch-up-gated leadership — a new leader is announced to your app only after its state machine has applied everything committed before the election, so you never serve stale reads from a "leader" that is still replaying.
  • Pluggable log storage (LogStore):
    • SegmentLogStore (default) — a preallocated segment-file WAL with ~10-25x lower device write amplification than an LSM store under synced append load. A synced append is one pure data write: no compaction, no filesystem-journal traffic. Purge unlinks whole segments. Built for consumer SSDs whose SLC caches choke on sustained tens-of-MB/s.
    • LevelLogStore — classic-level (LevelDB) backed alternative.
    • MemoryLogStore — for tests and ephemeral state machines.
  • Pluggable transport (RaftTransport): a built-in length-prefixed TCP transport (request-id correlated, lazy redial, timeout teardown), and an in-memory network (MemoryRaftNetwork) with partition injection for fast deterministic tests.
  • Typed errorsNotLeaderError (carries the current leader id for redirects), ReplicationLagError, RaftStoppedError.
  • Injectable logging — a structural, pino-compatible RaftLogger; silent by default.

Deliberate scope (read this before adopting)

These are design decisions, not roadmap gaps:

  • Single-term leader semantics, no pre-vote. A partitioned node can bump terms and force an election on rejoin. Election windows default to ~1-2s (etcd-style) so real network + fsync latency never causes storms.
  • Static membership. The cluster is fixed at construction (peers); there is no joint-consensus reconfiguration.
  • Single-blob InstallSnapshot. Snapshots ship as one message; size your state machine snapshots accordingly (or return an empty buffer from buildSnapshot() to opt out of snapshotting and rely on log replay — that contract is supported and tested).
  • Snapshots pause the apply loop rather than forking state.
  • Peer wire format may change in 0.x minors — restart clusters together when upgrading. On-disk formats (segment WAL, LevelDB entries, snapshot blobs) are stable.

Quick start

import { RaftNode, SegmentLogStore, DEFAULT_RAFT_PARAMS } from "logboat";

const peers = [
  { nodeId: 0, host: "10.0.0.1", raftPort: 16001 },
  { nodeId: 1, host: "10.0.0.2", raftPort: 16001 },
  { nodeId: 2, host: "10.0.0.3", raftPort: 16001 },
];

const node = new RaftNode({
  nodeId: 0,
  peers,
  logStore: new SegmentLogStore("data/raft-log"),
  params: DEFAULT_RAFT_PARAMS,
  apply: async (logIndex, term, isLeader, payload) => {
    // Apply the committed payload to your state machine.
    // The return value is surfaced to the proposer on the leader.
    return myStateMachine.apply(payload);
  },
  buildSnapshot: () => myStateMachine.serialize(),
  installSnapshot: (data) => myStateMachine.restore(data),
  snapshotDir: "data/raft-snapshots",
});

await node.start();

node.onLeadership((leader) => {
  // Gate your request serving on this — it fires true only once caught up.
});

// On the leader:
const { logIndex, response } = await node.propose(encodeMyCommand(cmd));

Redirect handling on followers:

import { NotLeaderError } from "logboat";

try {
  await node.propose(payload);
} catch (e) {
  if (e instanceof NotLeaderError) redirectClientTo(e.leaderNodeId);
  else throw e;
}

Storage: why the segment WAL exists

Raft log storage has a peculiar shape: append at the head, purge from the tail after each snapshot, read only the recent window. LSM stores handle this badly under synced load — every group-commit fsync rewrites a WAL block and commits the filesystem journal, and compaction endlessly rewrites a key range that is being deleted from behind. Measured on real hardware, that turned ~1.3MB/s of logical raft data into ~34MB/s of device writes — enough to exhaust a consumer QLC SSD's SLC write cache in minutes and put the drive into periodic write-stall cycles.

SegmentLogStore writes into preallocated, zero-filled segment files, so a synced append touches only already-allocated data blocks (fdatasync, no journal metadata). Purge unlinks dead segments. The unpurged window also lives in memory (bounded by your snapshot interval), so reads never touch disk after recovery.

License

MIT