Flint 5 generates exceptions when leaving a room immediately after posting a message
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' }