#19110: fix(voice-call): handle EADDRINUSE crash on webhook server start
channel: voice-call
size: S
trusted-contributor
Cluster:
Session Management and Fixes
When the webhook port is already in use, the server crashes with an unhandled EADDRINUSE error.
Fix: Catch the error and retry with a fallback port, or surface a clear error message.
Recreated from #17050 with only relevant files.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
This PR adds EADDRINUSE error handling to the voice-call webhook server by retrying on sequential ports (up to 3 fallback attempts). The core retry logic in `webhook.ts` is sound — it correctly detects `EADDRINUSE`, increments the port, and re-throws non-EADDRINUSE errors. The `this.server = null` cleanup on error is a good defensive addition.
However, two issues need attention:
- **Test constructor mismatch**: The test file constructs `VoiceCallWebhookServer` with a single config-like object (`{ serve, providers }`), but the actual constructor expects four positional parameters `(config, manager, provider, coreConfig?)`. This will fail TypeScript type-checking. The `providers` key (plural) also doesn't exist on `VoiceCallConfig`.
- **Port fallback not visible to callers**: When the server falls back to a different port, `runtime.ts` still reads `config.serve.port` (the original port) for tunnel and Tailscale setup. This means tunnels would forward to the wrong port after a fallback, silently breaking webhook delivery.
<h3>Confidence Score: 2/5</h3>
- This PR has a test that won't compile and a logic gap where port fallback breaks tunnel configuration.
- Score of 2 reflects two concrete issues: (1) the test file uses an incorrect constructor signature that won't pass type-checking, and (2) when the server falls back to a different port, the tunnel/tailscale setup in runtime.ts still references the original (occupied) port, which would silently break webhook delivery in production.
- `extensions/voice-call/src/webhook-eaddrinuse.test.ts` needs constructor calls fixed. `extensions/voice-call/src/webhook.ts` and `extensions/voice-call/src/runtime.ts` need the fallback port to be propagated to tunnel callers.
<sub>Last reviewed commit: 8559c80</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#20491: fix: address EADDRINUSE on Nextcloud Talk webhook restart
by MisterGuy420 · 2026-02-19
77.4%
#17918: fix(telegram): start webhook listener before setWebhook + forward w...
by Glucksberg · 2026-02-16
73.8%
#6702: fix(voice-call): mark calls as ended when media stream disconnects
by johngnip · 2026-02-01
73.7%
#18852: fix: Voice-call state persistence is fire-and-forget, causing silen...
by coygeek · 2026-02-17
73.4%
#21288: Security/Voice: reject malformed Host headers in webhook+WS server
by bmendonca3 · 2026-02-19
72.7%
#23134: fix(gateway): skip auto-restart for webhook channels that resolve i...
by puneet1409 · 2026-02-22
72.3%
#11101: fix: handle AbortError and WebSocket 1006 in unhandled rejection ha...
by Nipurn123 · 2026-02-07
71.7%
#21197: Security/Voice Call: enforce exact webhook path matching
by bmendonca3 · 2026-02-19
71.5%
#21128: Security/Voice Call: require trusted proxy IPs for forwarded-header...
by bmendonca3 · 2026-02-19
70.7%
#9727: fix(whatsapp): retry reconnect loop on initial connection failure
by luizlf · 2026-02-05
70.6%