My Go API Returned 503 After 100 ms. The Handler Kept Running

I was looking at what happens after a Go HTTP handler times out. The client receives a 503 response, so the request appears finished from the outside. But the wrapped handler can still be running inside the process.
I wanted to separate two events that are easy to treat as one: sending a timeout response and stopping the work that produced it. In Go, the first can happen without the second. A context tells code that its result is no longer needed. It does not forcibly interrupt a goroutine that never checks the signal.
I wrote a small example with two handlers. They have the same HTTP timeout. One ignores request cancellation; the other waits either for permission to finish or for the request context to end. A channel holds the first handler open until the client has received its timeout response, so the central observation does not depend on an accurately timed sleep.
















