fix(msteams): await abort signal to prevent EADDRINUSE restart loop#25582
fix(msteams): await abort signal to prevent EADDRINUSE restart loop#25582byungsker wants to merge 1 commit intoopenclaw:mainfrom
Conversation
monitorMSTeamsProvider() returned immediately after expressApp.listen() bound to the port. The gateway's startAccount runner treats a resolved promise as "provider stopped" and schedules an auto-restart; the second bind attempt then fails with EADDRINUSE, producing an infinite restart loop until MAX_RESTART_ATTEMPTS is exhausted. Replace the fire-and-forget abort listener with an await-until-abort block: when an abortSignal is provided the function now stays pending until the signal fires, then calls shutdown() before returning. If the signal is already aborted on entry the shutdown is called immediately. When no abortSignal is provided the existing behaviour is preserved (server keeps running; caller can invoke shutdown() directly). Fixes openclaw#25527
|
Field report from a live production recovery (sanitized, no secrets / no env values). Posting this in case it helps maintainers and others triaging the same restart-loop class. Executive summaryWe hit a Microsoft Teams provider auto-restart loop with the same user-visible signature described here:
In our incident, there were three independent contributors. Fixing only one did not fully resolve the loop:
What we observed (timeline-style)Phase A — restart loop with repeated startup success signals
Phase B — eliminated local package-collision factor
Phase C — fixed missing credential config
Phase D — remaining behavior matches known monitor/lifecycle bug class
Distinguishing signals that helped triageThese indicators were the most useful to separate local misconfiguration from upstream bug behavior:
Secure remediation checklist that worked best for us(Generalized to avoid host-specific details) 1) Eliminate package duplication first
2) Validate Teams auth fields completely
3) Restart and verify by behavior, not process state
4) If still looping, classify as likely upstream lifecycle bug
What to include in repro data (high value for maintainers)Recommend sharing these artifacts (all sanitized):
Suggested maintainer-facing acceptance testA robust guardrail test for this bug class would assert:
Current status from this field report
If helpful, I can provide a compact sanitized log excerpt in follow-up showing exact line ordering (startup → resolution → restart) without any identifiers. |
|
Superseded by already-merged MSTeams monitor lifecycle fixes:
Closing this as duplicate to keep the queue focused. Thank you for the patch and write-up. |
Problem
monitorMSTeamsProvider()returned as soon asexpressApp.listen()bound to the port. The gateway'sstartAccountrunner treats a resolved promise as "provider stopped" and schedules an auto-restart; the second bind attempt then fails withEADDRINUSE, producing an infinite restart loop untilMAX_RESTART_ATTEMPTSis exhausted:Fix
Replace the fire-and-forget abort listener with an await-until-abort block so the
startAccountpromise stays pending while the HTTP server is running:Behaviour matrix:
This matches the pattern already used by the
zalousermonitor (extensions/zalouser/src/monitor.ts).Fixes #25527
Greptile Summary
Fixes the MS Teams provider's
EADDRINUSErestart loop by keeping themonitorMSTeamsProviderpromise pending until the abort signal fires, rather than resolving immediately afterexpressApp.listen()binds to the port.addEventListener("abort", ...)with anawait new Promisethat blocks until abort, followed byawait shutdown()— matching the established pattern inextensions/zalouser/src/monitor.tsConfidence Score: 5/5
Last reviewed commit: 1d92f36