Skip to content

[Bug]: MSTeams adapter: startMonitor() returns immediately causing EADDRINUSE restart loop #24522

@TurboArrowIV

Description

@TurboArrowIV

Summary

The MSTeams adapter's startMonitor() function in extensions/msteams/src/monitor.ts returns { app, shutdown } immediately after expressApp.listen() binds to the port. The gateway runtime interprets this resolved promise as "channel exited" and triggers the auto-restart mechanism. The restart attempts to bind a new Express server to the same port while the first is still listening, causing EADDRINUSE errors and an exponential backoff loop (up to 10 attempts).

Steps to reproduce

Configure MSTeams channel in openclaw.json
Start gateway: systemctl --user start openclaw-gateway
Observe logs: "starting provider (port 3978)" followed immediately by "auto-restart attempt 1/10"

Expected behavior

MSTeams adapter starts once and stays running.

Actual behavior

Adapter starts successfully (port 3978 binds, webhook responds with 401), but the runtime sees the function resolve and triggers restart. Subsequent attempts fail with EADDRINUSE.

OpenClaw version

Version: 2026.2.22-2, Node 22.22.0

Operating system

Ubuntu 24.04

Install method

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

Workaround: Add a blocking await before the return in monitor.ts:
await new Promise((resolve) => { httpServer.on("close", () => resolve());});return { app: expressApp, shutdown };
Also: @microsoft/agents-hosting (peer dependency of @openclaw/msteams) is not installed automatically by npm install -g openclaw. Users must manually run npm install @microsoft/agents-hosting inside the OpenClaw package directory.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions