← Back to PRs

#19110: fix(voice-call): handle EADDRINUSE crash on webhook server start

by Clawborn open 2026-02-17 11:33 View on GitHub →
channel: voice-call size: S trusted-contributor
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