juudd's request log writes one line when a request arrives and one line when it ends, and the ending line is triggered by close as well as finish. A response that the client cuts never emits finish, so a log that listens for finish alone loses the last line of every long-lived request, without a sound.
That is the decision. The rest of this post is how we found the hole, why the only thing that found it was a gate written for the purpose, and what the line says now.
We moved the HTTP framework, and nothing was broken
The first version of the server was an Express app, under 300 lines, and it was about to grow into the control plane. Express was not failing. There was no measured throughput problem. The reason to move to Fastify was a preference about the future, and a preference about the future is a legitimate reason that still has a cost, so the cost was written down before the move.
Two parts of it were real. Three helpers from the MCP SDK are shaped like Express and do not port, so they had to be reimplemented. And the MCP endpoint streams.
The request that does not finish
GET /mcp answers with an event stream, and one was measured staying open for 900 seconds. In Fastify a reply like that has to be hijacked, which takes it out of the framework's lifecycle, including the hook that would write the closing line of the request log.
The request log is evidence for this project, and it is read when something goes wrong. So the port had a gate written before it was attempted:
The port is not complete until a
[req>]and[req<]pair is observed for a streamingGET /mcpon a hijacked reply.
A 200 response does not demonstrate that, and neither does a passing review. The pair has to be watched.
What the gate found
The first port listened for finish on the raw response, which does survive the hijack. It still lost the closing line:
The cause was not Fastify. A stream cut by the client emits close and never emits finish. The Express version had exactly the same hole. Its own log, read again afterwards, showed a streaming request arriving with nothing after it.
So for every long-lived request since the log was introduced, the closing line had been silently absent, and only a gate that insisted on watching the stream surfaced it.
What the log does now
The closing line is written exactly once, on whichever of finish and close comes first, and it listens on the raw response because the framework's own response hook never fires for a hijacked reply, which is the exact request whose duration matters most.
A request that streams looks like this when it ends:
There are two details in it that are there on purpose.
- The arrival line exists because the closing one is late. A stream does not end for minutes, so a log with only closing lines shows a person watching it nothing, which is indistinguishable from a request that never arrived.
- The word
streamis there because the number means opposite things. For an ordinary request the duration is time spent working, and smaller is better. For a stream it is how long the connection survived, and larger is better. The same figure in the same position with no marker gets a healthy long connection read as a slow request, and that is what happened.
Whether a given /mcp request streams is decided per request by the transport, so the log reads the content type from what was written rather than from the route. The same route answers some calls with JSON in milliseconds and holds others open.
What the log never holds
Each line carries the path and the names of the query parameters, never their values. Sign-in puts code and state in the query string, those values are live credentials, and this log is read routinely. The names say which leg of a flow a request was. The values would be a leak.
How we kept the port small
The move was made in two steps that could each be checked on their own.
- Step one restructured the code on Express. A pure refactor, with the live sign-in flow as its regression test, so that if it broke the cause was unambiguous.
- Step two swapped the framework. Only two files know which framework is in use, so this step was small.
Doing both at once was rejected, because a failure would not have said which change caused it. The side effects went in our favour. We now own the bearer check and the discovery metadata instead of inheriting versions shaped like a framework, and the port ended with a better log than it started with, which was not the goal.
The rule, once
A request log writes a line when a request arrives and exactly one when it ends, however it ends, and it marks a stream as a stream. A change to the layer that writes it is not finished until the long-lived case has been watched, because the quiet failure is a missing line, and a missing line looks like a request still running. The tools and their limits are listed in the docs.