A check cut short by shutdown saves every port as closed and every certificate as failed #185

Closed
opened 2026-10-01 22:33:25 +02:00 by clawbot · 2 comments
Collaborator

When shutdown cancels a check that is under way, the rest of the check still runs, with the cancelled context. DNS lookups then fail and leave the saved state alone, because the resolver drops a query the context cut short. Port and TLS checks do not: a cancelled connection attempt is recorded as a closed port or a failed certificate check.

So a check on the DNS interval that is under way at shutdown saves every monitored port as closed and sends a Port Change notification for each one that was open. A check on the TLS interval saves every certificate as failed and sends TLS Failure. On the next start the real results come in and the watcher sends Port Change (now open) and TLS Recovery for all of them.

This could happen before, depending on timing. With the change for #114 the watcher's stop waits for the run loop to return, so the cut-short check always runs to its end, its notifications go out while the notifier still accepts them, and its results are saved.

Suggested fix: treat a port or TLS check the context cut short the way the resolver treats a cut-short query, and record and notify nothing for it.

Model: opus-5-5

When shutdown cancels a check that is under way, the rest of the check still runs, with the cancelled context. DNS lookups then fail and leave the saved state alone, because the resolver drops a query the context cut short. Port and TLS checks do not: a cancelled connection attempt is recorded as a closed port or a failed certificate check. So a check on the DNS interval that is under way at shutdown saves every monitored port as closed and sends a `Port Change` notification for each one that was open. A check on the TLS interval saves every certificate as failed and sends `TLS Failure`. On the next start the real results come in and the watcher sends `Port Change` (now open) and `TLS Recovery` for all of them. This could happen before, depending on timing. With the change for https://git.eeqj.de/sneak/dnswatcher/issues/114 the watcher's stop waits for the run loop to return, so the cut-short check always runs to its end, its notifications go out while the notifier still accepts them, and its results are saved. Suggested fix: treat a port or TLS check the context cut short the way the resolver treats a cut-short query, and record and notify nothing for it. Model: opus-5-5
clawbot added this to the 1.0 milestone 2026-10-01 22:34:34 +02:00
Author
Collaborator

Plan. It lands before #186 (#114), which makes this happen whenever shutdown falls during a check.

Definition of done:

  • A port or TLS check that the context cut short records nothing and notifies nothing, the way the resolver already drops a query the context cut short. A check that ran to completion is handled as today.
  • Tests: a port check and a TLS check run with a context cancelled during the check leave the saved port and certificate state as it was and send no notification; each test fails with the fix removed. The connections go to local listeners started in the test; nothing involving DNS is stood in for.
  • README, if it describes shutdown behaviour, says so.

Model: opus-5-5

Plan. It lands before https://git.eeqj.de/sneak/dnswatcher/pulls/186 (https://git.eeqj.de/sneak/dnswatcher/issues/114), which makes this happen whenever shutdown falls during a check. Definition of done: - A port or TLS check that the context cut short records nothing and notifies nothing, the way the resolver already drops a query the context cut short. A check that ran to completion is handled as today. - Tests: a port check and a TLS check run with a context cancelled during the check leave the saved port and certificate state as it was and send no notification; each test fails with the fix removed. The connections go to local listeners started in the test; nothing involving DNS is stood in for. - README, if it describes shutdown behaviour, says so. Model: opus-5-5
Author
Collaborator

Fixed in #188: a port or TLS check whose context was cancelled is now dropped by the watcher, the way the resolver drops a cut-short lookup. The test cancels the context before the check rather than during a connection; the PR says why.

Model: opus-5-5

Fixed in https://git.eeqj.de/sneak/dnswatcher/pulls/188: a port or TLS check whose context was cancelled is now dropped by the watcher, the way the resolver drops a cut-short lookup. The test cancels the context before the check rather than during a connection; the PR says why. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/dnswatcher#185