Skip to content

[Bug]: 2.0.6 will block the remote preview on some ATK's templates #487

@Alive-Fish

Description

@Alive-Fish

Bug Description

Bug Description

SDK v2.0.6 breaks on Azure App Service (IIS + iisnode) because HttpServer.start() calls parseInt(port, 10) on the PORT environment variable, which on Azure App Service is a Windows named pipe path, not a numeric port.

Environment

  • SDK version: @microsoft/teams.apps@2.0.6
  • Hosting: Azure App Service (Windows, IIS + iisnode, Node 22)
  • Works on: v2.0.5
  • Broken on: v2.0.6

Root Cause

On Azure App Service, iisnode sets the PORT environment variable to a Windows named pipe path like:

\\.\pipe\507cb72a-6765-4f1e-a9f0-1234abcd5678

In v2.0.6, HttpServer.start() (introduced in PR #433) converts the port to a number:

// packages/apps/src/http/http-server.ts
async start(port) {
    const portNumber = typeof port === 'string' ? parseInt(port, 10) : port;
    // ...
    await this._adapter.start(portNumber);
}

This results in:

parseInt('\\.\pipe\507cb72a-...', 10)  // → NaN

The server then calls http.Server.listen(NaN), which either fails silently or binds to a random port. iisnode can never reach the Node process, so all inbound requests time out with no response.

Why v2.0.5 works

In v2.0.5, HttpPlugin.onStart() passed the port value directly to http.Server.listen() without any type coercion:

// v2.0.5 HttpPlugin
async onStart({ port }) {
    this._server.listen(port, () => { ... });
}

Node's http.Server.listen() natively supports both numeric ports and named pipe strings — no conversion is needed.

Steps to Reproduce

  1. Create a Teams bot using @microsoft/teams.apps@2.0.6
  2. Deploy to Azure App Service (Windows, with iisnode — the default)
  3. Send a message to the bot in Teams
  4. Bot never responds — requests time out

Downgrading to @microsoft/teams.apps@2.0.5 resolves the issue immediately.

Suggested Fix

In HttpServer.start(), pass the port value through as-is instead of calling parseInt():

  async start(port: string | number) {
-   const portNumber = typeof port === 'string' ? parseInt(port, 10) : port;
-   // ...
-   await this._adapter.start(portNumber);
+   // Pass port as-is — http.Server.listen() handles both numbers and pipe paths
+   await this._adapter.start(port);
  }

The ExpressAdapter.start() and the underlying http.Server.listen() already handle both numeric ports and named pipe strings correctly. The same change should be reflected in the IHttpServerAdapter.start() type signature to accept string | number.

Related PRs

Steps to Reproduce

  1. Create a default-bot template from VS Code ATK.
  2. Provision
  3. Deploy
  4. Debug "View Remote App in Teams (xxx)".
  5. Install and open it.
  6. Say "hi" and will get no response.

Expected Behavior

Work as SDK v2.0.5.

Actual Behavior

Not work.

SDK Version

2.0.6

Node.js Version

22.22.0

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions