Blog

What Your Client Does When the Server Just… Stops

September 13, 2026Xerat023 min read
Share
What Your Client Does When the Server Just… Stops

Most error-handling code is written and tested against a server that answers, even if the answer is bad: a 500, a 503, a slow-but-eventually-arriving response. A server that accepts the connection and then simply never sends anything back — no status line, no headers, no body, socket just left open — is a different failure mode, and it's rare enough in practice that a lot of client code has genuinely never encountered it before it happens for the first time in production.

Timeout vs. reset: two different ways nothing comes back

A client-side timeout means your own code gave up waiting after some interval — the connection might still technically be alive on the server's end, or the server might eventually have answered. A connection reset is different: the server (or something between you and it — a proxy, a load balancer, a crashed process) actively tore down the TCP connection, and the client finds out immediately rather than after waiting out a timeout. Both look like "the request failed with no response" from a high level, but they're different failures with different likely causes, and code that only distinguishes "got a response" from "didn't" — without checking which kind of didn't — treats a crashed backend the same as a slow one, which usually isn't the right response in either direction.

Why this is hard to reproduce on purpose

Simulating a slow response is easy — add a delay. Simulating a malformed or truncated body is easy — send bad bytes. Simulating a connection that dies with zero bytes sent back, from a server that already started responding, is genuinely harder to construct on purpose, because most tools default to sending some kind of response, even an error one. Getting a socket to just close mid-flight, after headers were already committed, needs something that deliberately breaks the response stream at the transport level rather than returning a status code — a meaningfully different thing to build than "return a 500."

What this actually looks like to a real client

Running curl against a connection that resets mid-response produces a specific, recognizable failure — curl: (18) transfer closed with outstanding read data remaining — rather than any HTTP status code at all, because no valid HTTP response was ever completed. That's the tell: if error handling is written to switch on response.status, a dropped connection never reaches that branch, because there's no response object to have a status. It has to be caught as a network-level exception instead, and a surprising amount of production error handling only has one of those two paths actually wired up.

Building it on purpose

MockBase's chaos scenarios support a genuine connection reset: the route sends its status and headers, then the body stream deliberately raises instead of completing, which closes the socket without a valid terminator — the same thing a crashed backend process looks like to a client, and verified against a real client rather than just an in-process test transport. It's a narrower, rarer failure than a slow or malformed response, which is exactly why it's the one most retry and circuit-breaker code has never actually been exercised against.

X

Xerat02

Building MockBase.