Skip to content

Expose asynchronous HomeKit startup failures - #218

Merged
yfre merged 2 commits into
hap-java:masterfrom
lsiepel:fix/async-start-failures
Nov 27, 2026
Merged

yfre merged 2 commits into
hap-java:masterfrom
lsiepel:fix/async-start-failures

Conversation

@lsiepel

@lsiepel lsiepel commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

HomekitRoot.start() discards the future returned by HTTP listener startup and its advertising callback. If binding fails asynchronously, the caller sees a normal return, the failure is not logged, and the root remains marked as started without a listener or mDNS advertisement.

Add startAsync() returning a CompletableFuture<Void> so integrations can observe successful HTTP startup and service registration, or handle their failure. Exceptions thrown synchronously during startup also complete this future exceptionally through the same cleanup path. Keep the existing void start() entry point and log its startup failures. Reject duplicate starts without interrupting a pending startup or an already-running listener.

Failed startup resets the started state and stops the partially started root. This includes stopping the HTTP listener if only mDNS registration fails. This behavior also applies to the existing start() method: previously, the HTTP listener could remain available to already-paired controllers after an advertising failure; it is now stopped. This is documented in CHANGES.md and both entry points' API documentation.

Recovery is not automatic. Integrations must create a new server and root for another attempt because the default HomekitHttpServer cannot be restarted. Automatic retries and network-change coordination remain outside this PR; openhab/openhab-addons#22495 consumes the new API and implements recovery by rebuilding failed instances.

Related context: openhab/openhab-addons#13399 and openhab/openhab-addons#22221. The latter handles exceptions thrown during startup, but cannot observe a later failure hidden by HAP-Java.

Signed-off-by: Leo Siepel <leosiepel@gmail.com>
Signed-off-by: Leo Siepel <leosiepel@gmail.com>

@yfre yfre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@yfre
yfre merged commit b0269a1 into hap-java:master Nov 27, 2026
1 check passed
@lsiepel
lsiepel deleted the fix/async-start-failures branch November 27, 2026 15:14
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.

2 participants