Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flint 5 generates exceptions when leaving a room immediately after posting a message #19

Open
jpjpjp opened this issue Mar 24, 2018 · 0 comments
Assignees
Labels

Comments

@jpjpjp
Copy link
Contributor

jpjpjp commented Mar 24, 2018

Take this type of scenario:

flint.hears.phrase('leave', function(bot, trigger) {
  console.log("/leave fired");
  bot.say("OK.  I know when I'm not wanted...").text()
  .then(() => bot.room.exit())
  .catch(err => console.error(err.message));
});

The bot posts a message and then leaves a room which generates a POST to /messages and a DELETE to /memberships

After the membership is deleted the framework gets a webhook event for the messages/created events on the "I know when I'm not wanted.." message. When it does a GET on /messages/:id Spark returns a 404 because the bot no longer has a membership in the room.

This behavior is the same in Flint4 and Flint5, but Flint4 seemed to handle it better. (I noticed in node_sparky/lib/spark.js that there doesn't seem to be an explicit 404 handler). This might have reasonably been a 403 but that is not currently how spark operates.

Here is the exception that Flint5 generates in this case:

/leave fired
{ Error: recieved error 404 for a GET request to http://localhost:3210/messages/Y2lzY29zcGFyazovL2VtL01FU1NBR0UvODk5YTM5YTEtNDk3MC00N2EyLWFiNjUtOGY4MjgwYmU4MDIz
    at processError (/Users/jshipher/Temp/flint/node_modules/node-sparky/lib/spark.js:295:23)
    at processResponse (/Users/jshipher/Temp/flint/node_modules/node-sparky/lib/spark.js:326:16)
    at Request.EventEmitter.request.when.promise.request [as _callback] (/Users/jshipher/Temp/flint/node_modules/node-sparky/lib/spark.js:176:21)
    at Request.init.self.callback (/Users/jshipher/Temp/flint/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/jshipher/Temp/flint/node_modules/request/request.js:1081:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/Users/jshipher/Temp/flint/node_modules/request/request.js:1001:12) code: 404, type: 'ERR_STATUS' }
{ Error: recieved error 404 for a GET request to http://localhost:3210/messages/Y2lzY29zcGFyazovL2VtL01FU1NBR0UvODk5YTM5YTEtNDk3MC00N2EyLWFiNjUtOGY4MjgwYmU4MDIz
    at processError (/Users/jshipher/Temp/flint/node_modules/node-sparky/lib/spark.js:295:23)
    at processResponse (/Users/jshipher/Temp/flint/node_modules/node-sparky/lib/spark.js:326:16)
    at Request.EventEmitter.request.when.promise.request [as _callback] (/Users/jshipher/Temp/flint/node_modules/node-sparky/lib/spark.js:176:21)
    at Request.init.self.callback (/Users/jshipher/Temp/flint/node_modules/request/request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/jshipher/Temp/flint/node_modules/request/request.js:1081:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/Users/jshipher/Temp/flint/node_modules/request/request.js:1001:12) code: 404, type: 'ERR_STATUS' }
@nmarus nmarus self-assigned this Mar 26, 2018
@nmarus nmarus added the bug label Mar 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants