Skip to content

fix(bonjour): suppress ciao IPv4 address-change assertion crash#27359

Open
stone-jin wants to merge 1 commit intoopenclaw:mainfrom
stone-jin:fix/ciao-ipv4-assertion-crash
Open

fix(bonjour): suppress ciao IPv4 address-change assertion crash#27359
stone-jin wants to merge 1 commit intoopenclaw:mainfrom
stone-jin:fix/ciao-ipv4-assertion-crash

Conversation

@stone-jin
Copy link
Copy Markdown
Contributor

Summary

  • Problem: @homebridge/ciao fires assert.fail() inside MDNSServer.handleUpdatedNetworkInterfaces when a network interface's IPv4 address transitions between defined↔undefined (WiFi drop, VPN toggle, sleep/wake).
  • Why it matters: The assertion becomes an unhandled promise rejection that falls through to process.exit(1), crashing the gateway.
  • What changed: Extended ignoreCiaoCancellationRejection in src/infra/bonjour-ciao.ts to also match ciao's IPv4 address-change assertions, logging them as non-fatal warnings instead of letting them crash the process.
  • What did NOT change (scope boundary): No changes to the @homebridge/ciao dependency itself or other unhandled rejection logic.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Related: @homebridge/ciao upstream bug in MDNSServer.handleUpdatedNetworkInterfaces

User-visible / Behavior Changes

Gateway no longer crashes when network interfaces change (WiFi disconnect/reconnect, VPN toggle, sleep/wake). A warning is logged instead.

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Environment

  • OS: macOS
  • Runtime/container: Node 22+
  • Model/provider: N/A
  • Integration/channel (if any): mDNS/Bonjour discovery
  • Relevant config (redacted): N/A

Steps

  1. Start OpenClaw gateway with Bonjour advertising enabled
  2. Toggle WiFi off or disconnect VPN while gateway is running
  3. Observe gateway behavior

Expected

  • Gateway logs a warning and continues running

Actual (before fix)

  • Gateway crashes with AssertionError [ERR_ASSERTION]: Reached illegal state! IPV4 address change from defined to undefined!

Evidence

  • Failing test/log before + passing after
  • Trace/log snippets

Error trace before fix:

[openclaw] Unhandled promise rejection: AssertionError [ERR_ASSERTION]: Reached illegal state! IPV4 address change from defined to undefined!
    at MDNSServer.handleUpdatedNetworkInterfaces (.../@homebridge/ciao/src/MDNSServer.ts:695:18)
    at NetworkManager.checkForNewInterfaces (.../@homebridge/ciao/src/NetworkManager.ts:345:12)

New tests added in src/infra/bonjour-ciao.test.ts covering both assertion variants and unrelated error passthrough.

Human Verification (required)

  • Verified scenarios: All 11 bonjour tests pass (4 new + 7 existing)
  • Edge cases checked: Both IPv4 assertion variants (defined→undefined, undefined→defined), unrelated errors still propagate
  • What you did not verify: Live reproduction on hardware network toggle (error observed in production logs)

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery (if this breaks)

  • How to disable/revert this change quickly: Revert the single commit on src/infra/bonjour-ciao.ts
  • Files/config to restore: src/infra/bonjour-ciao.ts
  • Known bad symptoms reviewers should watch for: Gateway crashing on network changes (regression to current behavior)

Risks and Mitigations

  • Risk: Suppressing a ciao assertion that indicates a real bug could mask mDNS state corruption
    • Mitigation: The assertion is logged as a warning (logWarn), and the bonjour watchdog (60s interval) will attempt re-advertisement if the service falls out of announced state

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 26, 2026

Greptile Summary

Extended ignoreCiaoCancellationRejection to suppress @homebridge/ciao IPv4 address-change assertions that crash the gateway during network transitions (WiFi drops, VPN toggles, sleep/wake). The fix adds two new patterns to catch both assertion variants ("change" and "changed"), logs them as warnings instead of letting them propagate as unhandled rejections, and includes comprehensive test coverage for all scenarios.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The fix is narrowly scoped to suppress specific ciao assertions, includes comprehensive test coverage (4 new tests covering both assertion variants and edge cases), and maintains existing behavior for other error types. The suppressed assertions are logged as warnings for visibility, and the bonjour watchdog provides a safety net for mDNS state issues.
  • No files require special attention

Last reviewed commit: 1c3706a

@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 4, 2026
@openclaw-barnacle openclaw-barnacle bot removed the stale Marked as stale due to inactivity label Mar 26, 2026
@openclaw-barnacle
Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant