Pure Effect – Reproduce production bugs on your laptop without a DB

Hi HN,I think it's safe to say that the majority of developers don't give a second thought to writing code with I/O tangled in business logic. It's all too common to see code like: const user = findUser(email); if (!user) await saveUser(user);Now, you may ask: what's the big deal? When we write code like this, two things happen:1. It gets harder to debug production bugs. Unless you have the exact same database and remote API services to connect to, you may fail to reproduce the bug.2. You have to use mocks and fakes in your tests, or use test containers, which only help somewhat, and they are slow!To solve these issues, I built Pure Effect, a tiny TypeScript/JavaScript effect library. The core idea is simple: if a function performs I/O, it isn't pure. But if it returns a description of the I/O it wants to perform, it is. So instead of await findUser(email), you return a Command object that says, "I would like to call this function, and when it finishes, here's what to do next." Your business logic becomes a pure function. Same input, same output, every time. The database never gets touched until the interpreter (runEffect) runs.When I first started the library, I didn't expect just how far that one idea would stretch. Once your pipelines are just data, a lot of wonderful things become possible:- No need for mocking libraries. You walk the tree in tests and assert on its structure: assert.equal(flow.cmd.name, 'cmdFindUser'). Nothing is executed.- Wrap any effect with Retry(effect, { attempts: 3, delay: 200, backoff: 2 }). The configuration is plain data, so you can assert on it in tests.- Every command's input and output flows through the interpreter, so you get a full execution trace for free. You can write a simple timeTravel() function that replays it locally without touching any I/O. Perfect for debugging complex production bugs.- An onBeforeCommand hook sits between your busines

Hacker NewsToolAISource
0Sign in to voteCopy link

FL score

75

out of 100

Verdict

VALIDATE

high confidence

Competition

No competitor data yet

Trend

No signal yet

A TypeScript effect library that separates I/O from business logic to enable pure functions, easier debugging, and reliable reproduction of production bugs without a real database.

The pain

Developers struggle to reproduce production bugs and write reliable tests because business logic is tightly coupled with I/O operations like database calls, making debugging slow and error-prone.

The gap

Existing solutions rely on mocks, fakes, or test containers that are either incomplete or slow, and there is no widely adopted approach that makes business logic fully pure and testable without touching real I/O.

Build angle

Focus on building a robust, easy-to-adopt effect system that integrates smoothly with existing TypeScript/JavaScript codebases, emphasizing debugging tools and testability to reduce friction for developers.

Strengths

  • Addresses a real and common developer pain point around debugging and testing I/O-heavy code.
  • Innovative approach to making business logic pure by returning command descriptions instead of performing I/O directly.
  • Enables deterministic testing and local reproduction of production bugs without external dependencies.
  • Provides built-in retry and tracing mechanisms that improve reliability and observability.

Risks

  • Requires developers to adopt a new programming paradigm which may have a learning curve and resistance.
  • Potential integration challenges with existing codebases and libraries that expect direct I/O calls.
  • Unclear if the performance overhead or complexity introduced by the effect system is acceptable in large-scale applications.
  • Market adoption risk since similar concepts exist but have not become mainstream in JavaScript/TypeScript ecosystems.

Questions about this idea?

FlyBot reads the scoring and gives you a second opinion on “Pure Effect – Reproduce production bugs on your laptop without a DB”.

Open FlyBot