microsoft / teams-ai

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

[Bug]: Bot throws exception if an external API call takes more than 24 seconds #1647

Open donmanthorr opened 1 month ago

donmanthorr commented 1 month ago

Language

C#

Version

latest

Description

When making an external API call, the bot throws a TaskCanceledException if the call takes longer than 24 seconds. Previous TeamsActivityHandler bots did not have this limitation--they would successfully process such requests.

The bot waits until the call is complete and then throws an exception. For example, if the call takes 30 seconds, the bot will wait 30 seconds and then throw the exception. If the call takes 60 seconds, the bot will wait 60 seconds and then throw the exception.

I've simulated this behaviour by creating a simple bot based on the Echo bot sample. I changed the Activity handler to the code below and verified the behavior by modifying the delay value.

app.OnActivity(ActivityTypes.Message, async (turnContext, turnState, cancellationToken) => { var delay = 10; await turnContext.SendActivityAsync($"Starting wait for {delay} seconds", cancellationToken: cancellationToken); await Task.Delay(TimeSpan.FromSeconds(delay), cancellationToken); await turnContext.SendActivityAsync("Ending wait", cancellationToken: cancellationToken); });

Reproduction Steps

1. Clone Echo bot sample
2. Change Activity Handler to sample in description
3. Set delay to 10
4. Send bot a message. Both start and end message will appear
5. Change the delay to 60
6. Send bot a message.  Start message will appear and 60 seconds later an error message will appear (TaskCanceledException thrown)
donmanthorr commented 1 month ago

Hi there,

Any update on this issue? Unfortunately it is preventing me from deploying the bot.