Mohamed Amin
Mohamed Amin

Reputation: 1

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

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.

Upvotes: 0

Views: 212

Answers (2)

Miguel Hughes
Miguel Hughes

Reputation: 127

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;
});

Upvotes: 0

Mohamed Amin
Mohamed Amin

Reputation: 1

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); 

Upvotes: 0

Related Questions