microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jagdish-kumawat opened this issue · comments

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)

@jagdish-kumawat

  • Do you have a minimal repro bot that can exhibit the issue?
  • How long is the delay ("after some time")?
  • Does it just happen on Teams only, or other channels as well?
  • Is this using the legacy QnA or the newer CQA?

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.

commented

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.