Getting error "The reader's MaxDepth of 64 has been exceeded" while moving from a dialog to another many times in Bot Framework Emulator

208 views Asked by At

The problem appears when moving from one dialog to another many times or even when looping in the same dialog. After looping in the same dialog 9 times with many prompts inside it. An error raiesd from "OnTurnError"

value:"The reader's MaxDepth of 64 has been exceeded. Path 'DialogState.dialogStack.$values\[0\].
state.dialogs.dialogStack.$values\[0\].state.dialogs.dialogStack.$values\[0\].state.dialogs.dialogStack.$values\[0\].s
tate.dialogs.dialogStack.$values\[0\].state.dialogs.dialogStack.$values\[0\].state.dialogs.dialogStack.$values\[0\].
state.dialogs.dialogStack.$values\[0\].state.dialogs.dialogStack.$values\[0\].state.dialogs.dialogStack.$values\[0\].
state.dialogs.dialogStack.$values\[0\].state.dialogs.dialogStack.$values\[0\].state.options.Prompt.attachments.$values'."

I tried to empty the stack, change the MaxDepth but nothing changed. Is there any way to manage a long conversation with many prompts without getting this error.

2

There are 2 answers

2
Mohamed Amin On

When I pass dialog Id paramter for ReplaceDialogAsync method that starts the loop with InitialDialogId which is equals to nameof(WaterfallDialog) instead of nameof(ReviewSelectionDialog) which is the name of dialog that I want to repeat, the bot runs properly. But I still don't know why the new code works properly!

  • Previous code
return await stepContext.ReplaceDialogAsync(nameof(ReviewSelectionDialog), userProfile, cancellationToken); 
  • Modified
return await stepContext.ReplaceDialogAsync(InitialDialogId, userProfile, cancellationToken); 
0
Miguel Hughes On

My two cents: Changing the MaxDepth was not working for me either, until I upgraded the bot framework version to 4.19.0 or later.

<PackageReference Include="Microsoft.Bot.Builder.Dialogs" Version="4.19.0" />

After doing this the example code did work.

services.AddHttpClient().AddControllers().AddNewtonsoftJson(options =>
{
    options.SerializerSettings.MaxDepth = HttpHelper.BotMessageSerializerSettings.MaxDepth;
});