microsoft / botbuilder-js

Welcome to the Bot Framework SDK for JavaScript repository, which is the home for the libraries and packages that enable developers to build sophisticated bot applications using JavaScript.
https://github.com/Microsoft/botframework
MIT License
685 stars 281 forks source link

[BotBuilder-Core] Handle Uncaught Exceptions #1599

Closed Batta32 closed 4 years ago

Batta32 commented 4 years ago

Versions

What package version of the SDK are you using. botbuilder-core@4.7.0

What nodejs version are you using nodejs@10.8.0

What browser version are you using -

What os are you using Windows 7

Describe the bug

Give a clear and concise description of what the bug is. Having a Firewall configured in a deployed resource (e.g. Cosmos DB), the execution flow is stopped due to a Uncaught Exception when the bot is trying to reach to the resource. It would be helpful to manage these kind of unhandled exceptions.

image

To Reproduce

Steps to reproduce the behavior: Using a Skill in TypeScript from botframework-solutions repository.

  1. Open a terminal in the Skill's folder in order to deploy it executing the following command, providing the appId, appPassword, luisAuthoringKey and luisAuthoringRegion
pwsh.exe -File deployment\scripts\deploy.ps1 -name "<BOT_NAME>" -location "<LOCATION>" -appId "<APP_ID>" -appPassword "<APP_PASSWORD>" -luisAuthoringKey "<LUIS_AUTHORING_KEY>" -luisAuthoringRegion "<LUIS_AUTHORING_REGION>"
  1. Go to the Skill's resource group in Azure Portal
  2. Select the CosmosDB resource -> Firewall and virtual networks
  3. Choose the Allow access from: Selected networks, and configure a random IP in the firewall section in order to reproduce the 403 error when trying to access the resource

image

  1. Open an instance of Visual Studio Code at the root folder of the Skill
  2. Install the dependencies executing npm install
  3. Create a launch.json for debugging

image

  1. Press F5 to start debugging and wait for the Skill to be running
  2. In the Debugging options, select All Exceptions

image

  1. Open the Bot Framework Emulator
  2. Create a new Bot's connection passing the skill's endpoint (which was retrieved after the initialization), the appId and the appPassword values
  3. Send an utterance to the Skill (e.g.run sample dialog)
  4. Check that the debugging was stopped due to an Uncaught Exception
  5. As the exception is not managed by a try/catch sentence, the workflow is stopped and the conversation is not continued

Expected behavior

Give a clear and concise description of what you expected to happen. The Uncaught Exceptions should be correctly handled in the Promises.

image

Screenshots

If applicable, add screenshots to help explain your problem. -

Additional context

Add any other context about the problem here. In addition to this, we implemented the onTurnError handler in the Skill to handle all the uncaught exceptions - botframework-solutions#2900

[bug]

Stevenic commented 4 years ago

This is by design. We don't explicitly eat errors. You should implement onTurnError as you stated to catch exceptions raised while processing an activity and for exceptions that occur outside of a message flow you should add your own try/catch around setup calls or use process.on('uncaughtException')

Batta32 commented 4 years ago

Thanks @Stevenic, I'll close this issue as you mentioned it's by design.

We implemented the onTurnError handler in the TypeScript Skill of botframework-solutions#2900 to handle all the uncaught exceptions.