flint icon indicating copy to clipboard operation
flint copied to clipboard

Bug when bot leaves room (when storage is enabled)??

Open bradh11 opened this issue 8 years ago • 0 comments

Receiving an error message when bot leaves a room. I believe the .catch on line 1966 is the root cause. Removing the catch stops the error from occurring.

TypeError: driver.forget.call(...).catch is not a function
    at Flint.forgetByRoomId (/root/spaceman/node_modules/node-flint/lib/flint.js:1966:15)
    at Flint.despawn (/root/spaceman/node_modules/node-flint/lib/flint.js:1758:10)
    at Flint.onMembershipDeleted (/root/spaceman/node_modules/node-flint/lib/flint.js:1379:17)
    at /root/spaceman/node_modules/node-flint/lib/webhook.js:142:22
    at Layer.handle [as handle_request] (/root/spaceman/node_modules/express/lib/router/layer.js:95:5)
    at next (/root/spaceman/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/root/spaceman/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/root/spaceman/node_modules/express/lib/router/layer.js:95:5)
    at /root/spaceman/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/root/spaceman/node_modules/express/lib/router/index.js:335:12)
    at next (/root/spaceman/node_modules/express/lib/router/index.js:275:10)
    at /root/spaceman/node_modules/body-parser/lib/read.js:130:5
    at invokeCallback (/root/spaceman/node_modules/raw-body/index.js:224:16)
    at done (/root/spaceman/node_modules/raw-body/index.js:213:7)
    at IncomingMessage.onEnd (/root/spaceman/node_modules/raw-body/index.js:273:7)
    at emitNone (events.js:106:13)

With the lines below commented out, the error does not occur. Do we need this .catch here if we are throwing an error further below in the else statement?>

  // validate storage module forget() method
  if(typeof driver.forget === 'function') {
    Bot.prototype.forget = function(key) {
      var id = this.room.id;
      return driver.forget.call(driver, id, key);
    };

    Flint.prototype.forgetByRoomId = function(roomId) {
      return driver.forget.call(driver, roomId)
        // .catch(err => {
        //   // ignore errors when called by forgetByRoomId
        //   return when(null);
        // });
    };
  } else {
    throw new Error('storage module missing forget() function');
  }

bradh11 avatar Feb 02 '18 06:02 bradh11