Skip to content

fix: close the connection on @exit - #2875

Open
gkc wants to merge 24 commits into
trunkfrom
gkc-honour-exit
Open

gkc wants to merge 24 commits into
trunkfrom
gkc-honour-exit

Conversation

@gkc

@gkc gkc commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

- What I did

  • fix: an atServer closes the connection at once, writing nothing, when a client sends @exit, rather than answering it with AT0003
  • docs: the scenarios, in features/connection/exit.feature

- How I did it
See commits

- How to verify it
Tests pass, including all four live packs locally against this build

- Description for the changelog
fix: an atServer closes the connection, writing nothing, when a client sends @exit, rather than answering it with AT0003.

gkc added 15 commits October 16, 2026 17:40
Only the whole command @EXIT passes the command validator, on any
connection, so the listener closes the connection on it with nothing
written. Commands sent before it are answered, and anything after it
is not handled. A longer command that starts with @EXIT is judged as
the command it is, including when only its first 16 bytes have
arrived, and a command that only resembles it, such as exit, is
still answered AT0003.

The listener test that names this behaviour now asserts the close and
that nothing was written, and its file sets the atServer's atSign in
setUp rather than relying on an earlier test.
The scenario, and the DoS line's bound on how long closing the
connection waits for earlier replies to be sent.
The atServer closes a connection by destroying its socket, which drops
anything written to it that has not yet been handed on. So that a
reply written before @EXIT arrives whole, the listener flushes a
socket connection, waiting at most five seconds, before it closes it.
A WebSocket connection is closed without a flush.

The functional test file is formatted to its package's language
version.
The scenario, and an example row for a client connected over a
WebSocket.
The validator and WebSocket tests move beside the others, under the
scenario and example row each proves, and the new scenario's command
is also sent in one write. The catalogue's connection is marked
closed once it is closed, as the real one is, and its socket's flush
completes.
The warning names the connection. Unit tests now pin that the close
waits for the socket's flush, and that it waits no more than five
seconds.
The pol connection the lookup tests use moves to test/pol_peer.dart,
so another test can prove a peer by pol the same way.
The large-response test now waits for the update's own answer before
it measures the reply, and deletes its key at tear-down.
The WebSocket example asserts that nothing is logged, so dropping the
guard that skips the flush for a WebSocket goes red, and the
five-second bound gains a case whose flush throws at once, as a real
socket's does. The test FakeSocket's flush now completes, so the older
tests that send @EXIT take the path a working socket takes, the waits
poll rather than sleep, and two comments that state a constraint
become NOTEs.
An atSign with a multi-byte character can be split between two
reads, so the raw connection decodes its stream as a whole. Comments
that state a constraint become NOTEs, one that restated the code
goes, and the pol example's roles move to main's dartdoc.
@gkc
gkc requested a review from cconstab October 18, 2026 12:54
@gkc

gkc commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@cconstab enforcing @exit consistently (flush writes before closing socket)

@gkc gkc changed the title fix: close the connection on @exit fix: close the connection on @exit Oct 19, 2026
gkc and others added 9 commits October 19, 2026 20:18
listen and acceptRequests take one callback, and a WebSocket connection
takes the Socket it runs over. The WebSocket example now records what
reaches the WebSocket through addStream, the path its writes take, so a
reply to the exit command shows up there.
The atServer no longer flushes a socket connection, for up to five
seconds, before it closes it on the exit command, and no longer logs a
warning when that flush fails. It closes the connection the way it
closes one whose client has gone: a socket is destroyed, a WebSocket is
closed, and the connection leaves the pool. A reply still being sent to
a command that came before the exit command may lose its end.

The flush could not run once writes went through the write queue, which
binds the socket to a stream: it threw, and the close went ahead.

The unit tests of the flush, its five-second bound and its warning go
with it, and the examples that close on the exit command now check that
the connection leaves the pool.
The atServer no longer waits for earlier replies to be sent before it
closes a connection on the exit command, so a large reply sent just
before it may lose its end, and nothing tests that it arrives whole.
The scenario that a large response sent before the exit command arrives
whole is retired, with the five-second bound on waiting for it. The
feature says instead that the atServer does not wait for earlier answers
to be sent, so the end of a long one may not arrive, and that a client
needing an answer whole waits for it before sending the exit command.
A merge from trunk kept the at_commons 5.22.0 line beside the 5.23.0
line that replaced it, so the 3.18.0 section is back to what trunk has.
The line now says only that the atServer closes the connection, writing
nothing, on the exit command, rather than answering it with AT0003. It
opens a 3.20.1 section, since 3.20.0 has shipped, rather than staying in
the 3.18.0 section where a merge from trunk had left it.
A reply to the exit command binds the WebSocket's write queue, which
holds back the close, so the example checked the close first and went
red on it rather than on the reply. It now checks what was written
first, and names it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant