Liking cljdoc? Tell your friends :D

2026-12-01 — An answer that never began, and a client kept after its node stopped

A fourth review, of the tree the entry before this left. Four findings, each with a test and a proposed fix. All four tests failed against that tree. Two fixes are taken as proposed. The third is made a refusal and the fourth is taken in a smaller form, and why is said where each comes up.

An upload carried no peer

The gateway forwards an upload with the address its client came from, as it does a call, and the transport handed the router no address for one. The envelope said null, and the node's exchange had an empty host for a remote address. Nothing on a node reads an upload's peer yet, so nothing went wrong for a client. The transport hands it over now.

An answer closed before it began

A handler that throws before it has given its exchange a status leaves the exchange to be closed with nothing sent. The node said that as an end, the one that finishes an answer. The gateway took it for an answer of nothing and closed the client's connection without a byte on it: tried against a gateway, an upload's client got HTTP/1.1 header parser received no bytes. Said as abort, the same request is answered 502 with the node's name, and a call gets the refusal a gateway writes for a node that did not answer.

A node now gives up an exchange closed before it had a status.

A welcome with a cadence that cannot be kept

The node took whatever cadence a welcome named. It is slept on by the loop that reports and watches for a gateway gone quiet: a negative one ends that loop for good, zero spins it, and anything that is not a number ends it too. No gateway of this revision sends one. The welcome is what is checked before any of it is acted on, though, and the cadence was the one part of it acted on unchecked.

The reviewer's fix kept the opening cadence and took the rest of the welcome. A welcome is taken whole or not at all, so it is refused here as one in another revision is: the node prints why once and dials again. A welcome that names no cadence is refused with them, where it was taken and the opening cadence kept.

A client kept after its node stopped

A node that had dialled kept its HTTP client when it stopped, for the answers it still owed, and never closed it. Measured over twenty starts, attaches and stops in one JVM (JDK 27): fifteen of the client's worker threads and twenty-five descriptors were left, and the first collection freed them all. So the client was reclaimed, but when the collector next ran and not when the node stopped.

The reviewer counted every use of the client, in seven places, and closed it when the count reached zero on a stopped node. That works: the same measurement shows nothing left after the last stop. It is also a count that every later use of the client has to remember to keep.

What is kept here counts one thing, the gateway's requests being served, because their answers are the only thing said with the client after a stop that anyone waits for. The client is shut when the last of them is done, at once when there is none. A shut client refuses what is asked of it afterwards, and the rest of what speaks with it — a registration, a report, a pong, an abort said again — already takes a gateway that does not answer. A request that arrives as the node stops is not counted and not served, where the reviewer's fix did the same. The same measurement: the descriptors are back as the last stop returns, three worker threads are still finishing then, and none is left a second later. The client is shut without waiting for what it has under way, so that a stop waits on nothing the network owes.

Shutting it at the stop whatever is being served is not enough: a call that stops its own node is still owed its answer, and the suite has that case.

Shown

The node's, the gateway's and the lifecycle suites, 134 tests and 533 assertions, against each removal alone:

removedfailurestest
the peer handed to the router for an upload1an-upload-carries-the-clients-peer
giving up an exchange closed before a status1a-handler-that-throws-before-answering-aborts
the refusal of a cadence that cannot be kept2a-welcome-that-names-no-cadence-to-keep-is-not-an-attachment
shutting a dialled node's client1a-stopped-node-closes-its-client-once-idle
waiting for what is being served before shutting it1 errora-batch-is-served-as-the-node-that-took-it

The whole suite: 303 tests and 1,201 assertions, without a failure.

Not shown: any of this between two JVMs. The measurement and the trial against a gateway were made in the suite's one JVM, with the other side of the wire played by hand.

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close