microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.45k stars 2.44k forks source link

[OnTurnError] unhandled error : The CancellationTokenSource has been disposed. #6643

Closed jagdish-kumawat closed 5 days ago

jagdish-kumawat commented 3 months ago

I am getting this error when user stops the chat and comes after some time to continue the conversation. The bot stops responding until I restart the app service. I am using teams channel. I am on latest version of bot framework c#.

This only happens if they are in repeated child dialog. I have a child dialog handling Q&A and I only exit that child dialog when user says exit, cancel, home etc.

Here is the stack trace -

Microsoft.Bot.Builder.Integration.AspNet.Core.IBotFrameworkHttpAdapter[0] 2024-04-16T08:26:14.1498802Z [OnTurnError] unhandled error : The CancellationTokenSource has been disposed. 2024-04-16T08:26:14.1510465Z System.ObjectDisposedException: The CancellationTokenSource has been disposed. 2024-04-16T08:26:14.1685928Z at Microsoft.Bot.Builder.ShowTypingMiddleware.FinishTypingTaskAsync(ITurnContext turnContext) 2024-04-16T08:26:14.1701899Z at Microsoft.Bot.Builder.ShowTypingMiddleware.ProcessTypingAsync(ITurnContext turnContext) 2024-04-16T08:26:14.1976692Z at Microsoft.Bot.Builder.ShowTypingMiddleware.OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken) 2024-04-16T08:26:14.2164601Z at Microsoft.Bot.Builder.Teams.TeamsSSOTokenExchangeMiddleware.OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken) 2024-04-16T08:26:14.2258972Z at Microsoft.Bot.Builder.MiddlewareSet.ReceiveActivityWithStatusAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) 2024-04-16T08:26:14.2268689Z at Microsoft.Bot.Builder.BotAdapter.RunPipelineAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken)

dmvtech commented 3 months ago

@jagdish-kumawat

tracyboehrer commented 1 week ago

By any chance is the TurnContext being cached and used after the turn is over? The TurnContext is only valid during the current turn and is subsequently disposed.

dmvtech commented 5 days ago

Closing due to lack of response. If you have additional information that will help us troubleshoot, please let us know and we will reopen and continue.