question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[NodeJS] ERROR: Too many calls to session.endDialog()

See original GitHub issue

I’ve been refactoring our full Botkit code to botbuilder this past days and so far it has been and it has been great in taking a major load of the code in managing dialogs (-ues).

I’m currently working with v0.9.x, and while its been great, I’d like to ask on why and what plans are ahead on the ERROR: Too many calls to session.endDialog().-response I get when an error is thrown within the code.

Reason being, it doesn’t give me any meaningful idea on what caused the issue. Are there any tips or commands I’m missing?

Thanks! #

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Steveniccommented, Apr 23, 2016

So the other issue I noticed is with your respondToSpecificFoo() function. You call session.endDialog() which of itself is fine. It will pop that dialog off the stack and return control to the dialog you came from (think of it as calling close window.) The issue is in your async callback for SomeApi.getSpecificFoo() you’re then calling session.send(). I’m assuming this is working ok but it’s a little dangerous.

The reason why its dangerous is that you’ve already ended your dialog (closed the window) and now you’re trying to say stuff in that context. In most cases nothing overly bad is going to happen, especially with send() but say you tried to call beginDialog() instead, you would totally jackup your callstack. So as a best practice you should avoid doing stuff like this. So how to do this the right way? You should move your endDialog() call into your callback and combine it with the send():

function respondToSpecificFoo(session, results) {
    var targetDate = moment(results.response.date);

    SomeApi.getSpecificFoos(targetDate, function (err, totalFoos) {
        var queryResponse = '';

        if (moment().isSame(targetDate, 'day')) {
            queryResponse = 'You have ' + totalFoos.toLocaleString() + ' foos for today!';
        } else {
            queryResponse = 'You have ' + totalFoos.toLocaleString() + ' foos for ' + moment(targetDate).format('MMMM D, YYYY') + '!';
        }

        session.endDialog(queryResponse);
    });
}
0reactions
deubakacommented, Apr 23, 2016

@Stevenic Thank you for tip. I’ve changed the code and yes, it does go away so far.

I’ll go ahead and make changes to our code accordingly if any, and await for a new release. Thanks! 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

[NodeJS] ERROR: Too many calls to session.endDialog() #167
So the other issue I noticed is with your respondToSpecificFoo() function. You call session.endDialog() which of itself is fine. It will pop ...
Read more >
node.js - ERROR: Too many calls to session.endDialog() with MS ...
I have having a play with this to create one for a fictional utility company, and looking at using LUIS to interpret my...
Read more >
Errors | Node.js v19.3.0 Documentation
Errors that occur within Asynchronous APIs may be reported in multiple ways: Most asynchronous methods that accept a callback function will accept an...
Read more >
Microsoft/BotBuilder - Gitter
I also see in the console: ERROR: Too many calls to session.endDialog(). but im not making ANY calls to endDialog. ideas? Alex Sorokoletov....
Read more >
Database Engine events and errors - SQL Server
Too many table names in the query. The maximum allowable is %d. 107, 15, No, The column prefix '%.*ls' does not match with...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found