watcher: a stop during the first scan sends no startup notification (closes #271) #279

Merged
clawbot merged 1 commits from fix/271-no-startup-notification-on-stop into next 2026-10-13 20:00:01 +02:00
Collaborator

Fixes #271.

Run sent the startup notification right after the first scan without looking at the context. RunOnce returns as usual when shutdown cuts the scan short, so stopping dnswatcher during its first scan sent "dnswatcher has started and completed its initial scan" to every endpoint as it shut down. Run now sends it only when the context was not cancelled; a scan that ran to the end still sends it, as TestSendTestNotification_ViaRun checks.

The new test, TestStopBeforeFirstScanSendsNoStartupNotification, runs a watcher configured with a hostname, the real resolver and the setting on, with its context already cancelled, and checks that nothing was notified. The resolver drops the lookup without sending a query, so the test sends no DNS traffic.

Judgement call: the test stops the watcher before the first scan, not part way through it. A stop part way through reaches the same check after RunOnce, and a test cancelling mid-scan would depend on timing.

Model: opus-5-5

Fixes https://git.eeqj.de/sneak/dnswatcher/issues/271. `Run` sent the startup notification right after the first scan without looking at the context. `RunOnce` returns as usual when shutdown cuts the scan short, so stopping dnswatcher during its first scan sent "dnswatcher has started and completed its initial scan" to every endpoint as it shut down. `Run` now sends it only when the context was not cancelled; a scan that ran to the end still sends it, as `TestSendTestNotification_ViaRun` checks. The new test, `TestStopBeforeFirstScanSendsNoStartupNotification`, runs a watcher configured with a hostname, the real resolver and the setting on, with its context already cancelled, and checks that nothing was notified. The resolver drops the lookup without sending a query, so the test sends no DNS traffic. Judgement call: the test stops the watcher before the first scan, not part way through it. A stop part way through reaches the same check after `RunOnce`, and a test cancelling mid-scan would depend on timing. Model: opus-5-5
clawbot added the needs-review label 2026-10-13 19:20:28 +02:00
clawbot self-assigned this 2026-10-13 19:20:28 +02:00
Author
Collaborator

Review: PASS
Needs rebase: TODO.md only

Model: opus-5-5

Review: PASS Needs rebase: TODO.md only Model: opus-5-5
clawbot added needs-rebase and removed needs-review labels 2026-10-13 19:43:50 +02:00
clawbot added 1 commit 2026-10-13 19:47:59 +02:00
Run sent the startup notification right after the first scan without
checking the context. RunOnce returns as usual when shutdown cuts the
scan short, so a stop during the first scan sent "has started and
completed its initial scan" to every endpoint as the process shut down.
Run now sends it only when the context was not cancelled.

The new test cancels the context before Run starts, so the scan never
sends its lookup; a stop part way through a scan follows the same path.

Model: opus-5-5
clawbot force-pushed fix/271-no-startup-notification-on-stop from 2555714086 to bb343bd44d 2026-10-13 19:47:59 +02:00 Compare
clawbot removed the needs-rebase label 2026-10-13 19:59:59 +02:00
clawbot merged commit 3592302615 into next 2026-10-13 20:00:01 +02:00
clawbot deleted branch fix/271-no-startup-notification-on-stop 2026-10-13 20:00:03 +02:00
Sign in to join this conversation.