Mikael Lirbank

Mikael Lirbank

@lirbank.com

I help companies build reliable software, focusing on AI and web technologies https://www.lirbank.com/ Author of https://www.npmjs.com/package/neon-testing

45 followers32 following52 posts

Let's gooooo!

ElectricSQL@electric.ax

Introducing Electric Agents! Agents are not compute. Agents are data. Multi-agent is a sync problem. Electric Agents is the first agent platform built on sync. Use it to build scalable, collaborative, long-lived multi-agent systems: 🧵👇

1/ Some constraints are real. Some are assumptions that sound plausible and never get tested. It's worth knowing which is which before they shape your decisions. I had one recently. 🧵

View full thread

6/ The cross-provider penalty is effectively zero when both providers have data centers in the same metro. Provider boundaries and geographic proximity are not the same constraint.

1/ Some constraints are real. Some are assumptions that sound plausible and never get tested. It's worth knowing which is which before they shape your decisions. I had one recently. 🧵

View full thread

4/ The thing that actually matters: geographic distance. Same Cloudflare infrastructure, same database, different regions: Far (San Jose → Virginia): 742ms Near (Ashburn → Virginia): 31ms That's 23x. Distance is real.

5/ The thing that doesn't matter: provider boundaries. Near Cloudflare Workers (internet) vs Vercel on AWS (internal network), same region: node-postgres: 31ms vs 32ms Postgres.js: 38ms vs 36ms In some configurations, crossing the internet was faster.

1/ Some constraints are real. Some are assumptions that sound plausible and never get tested. It's worth knowing which is which before they shape your decisions. I had one recently. 🧵

2/ Conventional wisdom: your database and application need to be on the same cloud provider. Cross-provider means crossing the internet, and crossing the internet means slow. It's the kind of thing that drives platform choices.

3/ I was working on a Cloudflare Workers deployment with Postgres on AWS. No managed Postgres on Cloudflare — cross-provider was the only option. So I benchmarked it: 4 Postgres drivers × 3 connection strategies × 3 deployment targets, 25 iterations each.

Good test coverage gives us confidence and prevents regressions. But testing for race conditions is hard. Even when tests run concurrently, the timing almost never lines up to trigger the bug. The test passes whether our code handles concurrency correctly or not.

View full thread

Good test coverage gives us confidence and prevents regressions. But testing for race conditions is hard. Even when tests run concurrently, the timing almost never lines up to trigger the bug. The test passes whether our code handles concurrency correctly or not.

View full thread

4. What we actually need is a write lock. The second transaction blocks until the first one commits, then reads the updated value. Race condition gone. But now we have a new problem - how do we prove the lock is actually doing its job?

5a. Synchronization barriers let us test for this. A barrier is a coordination point - each task runs until it hits the barrier, then waits. When the last task arrives, all are released at once. We get the exact race condition interleaving we need for our tests, manufactured on demand.

Good test coverage gives us confidence and prevents regressions. But testing for race conditions is hard. Even when tests run concurrently, the timing almost never lines up to trigger the bug. The test passes whether our code handles concurrency correctly or not.

2. Here's what that looks like. Two $50 credits hit an account with $100 at the same time. Both operations read the balance as 100. Both write 150. Final balance: $150 instead of $200. One credit vanished. No error. No rollback. Nothing in the logs.

3. Wrapping it in a transaction doesn't help. Postgres's default isolation level is read committed, which guarantees each statement sees only committed data - that's a read guarantee, not a write guarantee. Both transactions can still read the stale value before either writes.

Neon Testing v2.4.0 is out! 🎉 A Vitest utility for integration tests with Neon Postgres, now with: - Multi-role support for testing row-level security (RLS) - Multi-database project support github.com/starmode-bas... Big thanks to francesco-carrella for the contribution!

github.comRelease v2.4.0 · starmode-base/neon-testingWhat's Changed Role and database selection by @francesco-carrella in #10 New Contributors @francesco-carrella made their first contribution in #10 Full Changelog: v2.3.1...v2.4.0

I knew I've been pretty productive this year, but yeah, this is more than I expected... while the stats are kind of exciting, it may be time for a day off... 305 Cursor days this year so far

Right now I am using Ably to send notifications from step run functions to the client, so it can display progress. ably.com Curious to try Server-sent events at some point too. I wonder how well it will work with Vercel edge functions though. developer.mozilla.org/en-US/docs/W...

developer.mozilla.orgServer-sent events - Web APIs | MDNTraditionally, a web page has to send a request to the server to receive new data; that is, the page requests data from the server. With server-sent events, it's possible for a server to send new data...

So you know, these mean the same AWS data center: Vercel: Washington, D.C., USA (East) – iad1 Neon: AWS US East (N. Virginia) AWS Code: us-east-1 AWS Name: US East (N. Virginia) I find it especially helpful that @vercel.com name it "Washington, D.C" since AWS call it "N. Virginia".

For websites and e-commerce it is critical to display content with no delay. For apps it is important that the app is fast. For example, code splitting (and network calls) are actually a bad thing here. Loading JS when the user open a panel is making UX worse.

You are up to date.