Skip to content

[v0.10] Timeout for chain flow

Choose a tag to compare

@k0dep k0dep released this 29 Mar 16:33
· 40 commits to master since this release

There were an issue the chain was hanging in memory if user does not answer the chain request (calls like AwaitText(), AwaitUpdate() and AwaitQuery()) and that cause memory leaks.

We've added a mechanism to break this dangling chains by the timeout.

How to configure this option

Add a key into connection string with name chain_timeout and set the value in TimeSpan format (value 0:0:5 - means 5 seconds, 0:5 - 5 minutes, etc).

ℹ️ Default value is 1 hour

Example:

"botf": "123456:MAHHFJSMFNJASKFNSALVDMD?chain_timeout=0:2"

How to handle timeout

We've added new type to handle these events - Handle.ChainTimeout
Example of a code:

[On(Handle.ChainTimeout)]
void ChainTimeout()
{
    PushL("timeout");
}

Or you can specify custom handle for any of calls AwaitText(), AwaitUpdate() and AwaitQuery() by passing a delegate with your custom implementation
Example:

var name = await AwaitText(() => Send("Use /start to try again"));