microsoft / teams-ai

SDK focused on building AI based applications and extensions for Microsoft Teams and other Bot Framework channels
MIT License
349 stars 142 forks source link

[Bug]: Making debugger log to 'azureopenai:server' namespace prevents both local and testtool environments from starting #1763

Open donatas-xyz opened 1 week ago

donatas-xyz commented 1 week ago

Language

Javascript/Typescript

Version

1.3.1

Description

Not an expert, so just sharing my observations here.

Using debug output streams in MS Teams chatbot's server.listen() method stops web browser from opening to either install the app in local environment or to launch the app in testtool.

There's only one example of this logic within Teams AI samples here: https://github.com/microsoft/teams-ai/blob/3ec61e6e6fa267a7cb994aa35f13f2b93da9912e/js/samples/04.ai-apps/h.datasource-azureOpenAI/src/index.ts

Reproduction Steps

  1. Open an existing or create a new MS Teams chatbot.
  2. Add the following lines to the index.ts file:
    
    import debug from 'debug';

const log = debug('azureopenai:server'); log.log = console.log.bind(console);

3. Replace `console.log` part(s) within `server.listen()` method with just `log`. It will look something like this: 
```typescript
const server = restify.createServer();
const port = process.env.port || process.env.PORT || 3978;

server.use(restify.plugins.bodyParser());

server.listen(port, () => {
  //console.log(`listening on ${port} 🚀`);
  //console.log(`\nBot Started, ${server.name} listening to ${server.url}`);
  log(`listening on ${port} 🚀`);
  log(`\nBot Started, ${server.name} listening to ${server.url}`);
});
  1. Add debug dependencies to the package.json file:
    "devDependencies": {
        "@types/debug": "^4.1.12",
        "debug": "^4.3.5",
    }
  2. Install debug with npm install debug, if necessary.
  3. Terminal window will show the following - stopping right before the logging function:
    [nodemon] starting `node --inspect=9239 -r ts-node/register ./src/index.ts`
    Debugger listening on ws://127.0.0.1:9239/e4e12f8c-bcb1-4612-bc00-603f7ea0cxxx
    For help, see: https://nodejs.org/en/docs/inspector
    (node:29632) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
    (Use `node --trace-deprecation ...` to show where the warning was created)