Skip to content

Fix HapMonitor sockets never reconnecting after same-port HAP instance restart (#43)#49

Merged
NorthernMan54 merged 17 commits into
latestfrom
beta-4.0.4
May 6, 2026
Merged

Fix HapMonitor sockets never reconnecting after same-port HAP instance restart (#43)#49
NorthernMan54 merged 17 commits into
latestfrom
beta-4.0.4

Conversation

@NorthernMan54
Copy link
Copy Markdown
Contributor

No description provided.

NorthernMan54 and others added 12 commits April 26, 2026 17:31
…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>
@NorthernMan54 NorthernMan54 requested a review from Copilot May 5, 2026 23:34
@github-actions github-actions Bot added the fix label May 5, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 instanceBlacklist handling 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.

Comment thread src/monitor.ts Outdated
Comment thread CHANGELOG.md Outdated
Comment thread CHANGELOG.md Outdated
Comment thread CHANGELOG.md Outdated
NorthernMan54 and others added 4 commits May 5, 2026 19:40
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>
@NorthernMan54 NorthernMan54 requested a review from bwp91 May 5, 2026 23:44
@NorthernMan54 NorthernMan54 enabled auto-merge (squash) May 5, 2026 23:45
@NorthernMan54 NorthernMan54 merged commit 7492323 into latest May 6, 2026
12 checks passed
@NorthernMan54 NorthernMan54 deleted the beta-4.0.4 branch May 6, 2026 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HapMonitor sockets are never reconnected after a same-port HAP instance restart

5 participants