-
Notifications
You must be signed in to change notification settings - Fork 29
Description
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) // → NaNThe 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
- Create a Teams bot using
@microsoft/teams.apps@2.0.6 - Deploy to Azure App Service (Windows, with iisnode — the default)
- Send a message to the bot in Teams
- 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
- Introduce HttpServer (and begin deprecating HttpPlugin) #433 — Introduce HttpServer (and begin deprecating HttpPlugin) — where
parseIntwas introduced - Upgrade to express v5 #442 — Upgrade to Express v5
- Simplify HTTP Plugin architecture #424 — Simplify HTTP Plugin architecture
Steps to Reproduce
- Create a
default-bottemplate from VS Code ATK. - Provision
- Deploy
- Debug "View Remote App in Teams (xxx)".
- Install and open it.
- 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