"Error: Cannot update context after 'send' action" what does it mean

This issue has been tracked since 2017-03-21.

Error: Cannot update context after 'send' action

Can someone please explain to me what does this error mean and why I'm having it
Also It would be wonderful if you provide a more detailed documentation.
or could someone point to to a more comprehensive tutorial about node-wit.

EliteMarauder wrote this answer on 2017-04-15

me too, i got the same error

NatashaKSS wrote this answer on 2017-05-13

I was puzzled too at first, but I have a hunch that it might be due to this part of the code at line 105 of https://github.com/wit-ai/node-wit/blob/master/lib/wit.js:

return runAction(actions, 'send', request, response).then(ctx => {
  if (ctx) {
    throw new Error('Cannot update context after \'send\' action');
  }
  ... <some other code here>

I found that because I returned one of my own custom contexts during a send action to runAction, it triggered this if statement and produced the error. Ensuring that send action returns/resolves to null fixed it for me.

I guess that because 'send' actions are only supposed to be for sending messages to users, it shouldn't be used to update context...ehh...but I'm not too sure about the true reason here! Any additional advice is much appreciated!! :)

chessai wrote this answer on 2021-02-12

@NatashaKSS in the meantime, would you like to create a PR improving the error message?

NatashaKSS wrote this answer on 2021-04-01

@chessai Would love to, but whoops, looks like it's been quite some time now and the section of code I posted 3 years ago no longer exists in the codebase.

I figure that it may be due to runActions being removed in the 5.0.0 release, according to CHANGES.md. Perhaps we could close this issue since it's probably outdated by now?

More Details About Repo
Owner Name wit-ai
Repo Name node-wit
Full Name wit-ai/node-wit
Language JavaScript
Created Date 2016-04-12
Updated Date 2022-12-02
Star Count 1928
Watcher Count 98
Fork Count 497
Issue Count 36

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date