botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Question] Dialog state lost on exception

Open LTsLlama opened this issue 9 years ago • 12 comments

We implemented global exception handling for our bot that works as expected, except if a Dialog currently throws and exception it's state is lost.

How can we ensure a Dialog is still serialized even if it throws and exception?

LTsLlama avatar Jun 02 '17 07:06 LTsLlama

@DL-LiveTiles Are you using .NET or Node SDK?

nwhitmont avatar Jun 02 '17 15:06 nwhitmont

@nwhitmont .NET SDK. Sorry, will remember to add next time.

LTsLlama avatar Jun 04 '17 23:06 LTsLlama

Any insight on how to persist Dialog state after an exception?

LTsLlama avatar Jun 08 '17 02:06 LTsLlama

@DL-LiveTiles Have you tried anything that uses a more permanent storage method? Maybe save the state to a db with the username or any other useful data?

JasonSowers avatar Jun 08 '17 15:06 JasonSowers

@JasonSowers No, using the built-in Dialog state. Is rolling your own custom state the recommended way? I don't need more permanent storage, I would just like the Dialog to not lose state on an exception.

LTsLlama avatar Jun 09 '17 01:06 LTsLlama

Implemented custom Azure Storage for bot data using BotBuilder-Azure, but the issue still persists.

LTsLlama avatar Jun 26 '17 12:06 LTsLlama

@DL-LiveTiles can you share your implementation?

JasonSowers avatar Jun 26 '17 15:06 JasonSowers

@JasonSowers I cannot share my version, but here is a sample: https://github.com/Microsoft/BotBuilder-Azure/tree/master/CSharp/Samples/AzureTable

LTsLlama avatar Jun 27 '17 03:06 LTsLlama

Hi @DL-LiveTiles

Please provide a bare-bones example of the behavior you're seeing.

I spoke with the engineers who wrote the dialog stack, and they pointed out that "The stack and data bags get persisted even if there is an exception thrown by the dialogs in the stack: https://github.com/Microsoft/BotBuilder/blob/master/CSharp/Library/Microsoft.Bot.Builder/Dialogs/DialogTask.cs#L485

They also stated: "The problem that you are seeing is that the exceptions bubble up through the stack until a dialog on the stack handles the exception, if not it reaches the root loop dialog. This means that the conversation is reset to the initial state (dialog stack) because of the unhandled exception."

EricDahlvang avatar Jul 27 '17 22:07 EricDahlvang

Please reopen this issue if needed

JasonSowers avatar Aug 08 '17 22:08 JasonSowers

Hi @EricDahlvang,

Sorry for only getting back to you now, I was on another project and did not have time to look into this again.

What is the best way of globally handling exceptions on a dialog so that the exception does not bubble up and reset the initial state?

Thank you,

Douw

LTsLlama avatar Sep 11 '17 05:09 LTsLlama

Hi @DL-LiveTiles

You'll need to catch the exception in the dialog's code, and handle it there.

EricDahlvang avatar Oct 13 '17 23:10 EricDahlvang