Fix HapMonitor sockets never reconnecting after same-port HAP instance restart (#43)#49
Merged
Conversation
…e restart (#43) * Initial plan * initial plan Agent-Logs-Url: https://github.com/homebridge/hap-client/sessions/79bcc638-c35e-4093-9c3a-e1fe526846b1 Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com> * Fix HapMonitor sockets not reconnecting after same-port HAP instance restart Agent-Logs-Url: https://github.com/homebridge/hap-client/sessions/79bcc638-c35e-4093-9c3a-e1fe526846b1 Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com> * Fixes * Update package-lock.json --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com>
…the actions group (#48) * Create dependabot.yml * chore(deps): bump jannemattila/get-version-from-tag in the actions group (#44) Bumps the actions group with 1 update: [jannemattila/get-version-from-tag](https://github.com/jannemattila/get-version-from-tag). Updates `jannemattila/get-version-from-tag` from 3 to 4 - [Release notes](https://github.com/jannemattila/get-version-from-tag/releases) - [Commits](JanneMattila/get-version-from-tag@v3...v4) --- updated-dependencies: - dependency-name: jannemattila/get-version-from-tag dependency-version: '4' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps): bump viperproject/create-nightly-release Bumps the actions group with 1 update: [viperproject/create-nightly-release](https://github.com/viperproject/create-nightly-release). Updates `viperproject/create-nightly-release` from 1 to 2 - [Release notes](https://github.com/viperproject/create-nightly-release/releases) - [Commits](viperproject/create-nightly-release@v1...v2) --- updated-dependencies: - dependency-name: viperproject/create-nightly-release dependency-version: '2' dependency-type: direct:production update-type: version-update:semver-major dependency-group: actions ... Signed-off-by: dependabot[bot] <support@github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: NorthernMan54 <19808920+NorthernMan54@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR addresses a reconnection gap where HapMonitor sockets may stay dead after a same-port HAP instance restart, and also fixes instanceBlacklist enforcement during discovery for already-known instances.
Changes:
- Add monitoring/connection state helpers to
HapMonitor, and trigger a monitor refresh when an unchanged instance is re-announced but its socket is dead. - Fix
instanceBlacklisthandling so blacklisted instances are ignored before updating existing instances. - Add Vitest coverage for the new same-port restart logic and monitor socket state checks; update build/tooling and documentation.
Reviewed changes
Copilot reviewed 10 out of 12 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
tsconfig.json |
Adjust TypeScript compiler options (rootDir, node types, strict flag). |
src/monitor.ts |
Track monitoring state, harden socket cleanup on close, add isInstanceMonitored/isInstanceConnected. |
src/monitor.test.ts |
New unit tests for monitor connection-state helpers and close/finish behavior. |
src/interfaces.ts |
Extend HapEvInstance with monitoring flag. |
src/index.ts |
Enforce blacklist earlier and reconnect monitor on same-port restart with dead socket. |
src/index.test.ts |
Add tests validating reconnection path for same-port re-announcement. |
README.md |
Document instanceBlacklist usage and broaden monitor-refresh description. |
package.json |
Version bump and dependency/tooling updates (incl. rimraf). |
package-lock.json |
Lockfile updates corresponding to dependency changes. |
CHANGELOG.md |
Add v4.0.4 entry for blacklist + restart handling changes. |
.npmignore |
Exclude dev-only files from npm package. |
.github/workflows/release.yml |
Update nightly release action version. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
donavanbecker
approved these changes
May 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.