fix: cancel queued advertisement after service destruction - #73
Conversation
|
Nice work — this is a clean fix for a genuinely awkward race, and I'm happy to take it. I checked it out and ran it rather than reading alone: lint, build and all 108 tests pass here too, and it merges into the current The part I looked hardest at is the ordering in const endPromise = this.end();
this.destroyed = true;Calling
One thing before merge: CI compares those character-for-character, so it is worth copying rather than retyping. Thanks for picking up #18 — that one has been sat there a while. |
eb9e17e to
17320bc
Compare
Coverage Report for CI Build 31269916575Warning No base build found for commit Coverage: 48.192%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
Closes #18.
What was happening
Calling
advertise()and immediately callingdestroy()could leave startup work waiting in the responder queue.By the time that work ran, the service—and sometimes its mDNS server—had already been shut down. CIAO would still begin probing and could throw
ERR_SERVER_CLOSEDor retain a ghost advertisement.This is the race originally described by @bauer-andreas in #18.
What changed
A destroyed service can no longer enter or continue the advertisement pipeline:
destroy()marks the service as destroyed before queued work can resume.Normal advertising, unpublishing, retries, and duplicate-destroy behavior are unchanged.
Testing
The regression test reproduces the old behavior: three probes, one announcement, and a service left behind after destruction.
With this fix:
Release note
Fixed a race that could continue advertising a service after it had been destroyed.