Skip to content

Not able to capture error in middleware or main botmaster file #16

Description

@abhishekchotaliya

In my application, I am generating access token with the api, which has a lifespan of around 2 hours.

After that access token expires, If I start the botmaster, then it is throwing following error:

Unhandled rejection StatusCodeError: 400 - {"error":{"message":"Error validating access token: The session is invalid because the user logged out.","type":"OAuthException","code":190,"error_subcode":467,"fbtrace_id":"********"}}
    at new StatusCodeError (/Users/abi/code/github/mcbotplatform/api/node_modules/request-promise-core/lib/errors.js:32:15)
    at Request.plumbing.callback (/Users/abi/code/github/mcbotplatform/api/node_modules/request-promise-core/lib/plumbing.js:104:33)
    at Request.RP$callback [as _callback] (/Users/abi/code/github/mcbotplatform/api/node_modules/request-promise-core/lib/plumbing.js:46:31)
    at Request.self.callback (/Users/abi/code/github/mcbotplatform/api/node_modules/request/request.js:185:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (/Users/abi/code/github/mcbotplatform/api/node_modules/request/request.js:1157:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
    at IncomingMessage.<anonymous> (/Users/abi/code/github/mcbotplatform/api/node_modules/request/request.js:1079:12)
    at Object.onceWrapper (events.js:313:30)
    at emitNone (events.js:111:20)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)

and after that, I am continuously getting this error when anyone sends any messages to my facebook bot(which is linked to botmaster)

Error: wrong signature
    at MessengerBot.__verifyRequestSignature (/Users/abi/code/github/mcbotplatform/api/node_modules/botmaster-messenger/lib/messenger_bot.js:174:13)
    at /Users/abi/code/github/mcbotplatform/api/node_modules/botmaster-messenger/node_modules/body-parser/lib/read.js:104:9
    at invokeCallback (/Users/abi/code/github/mcbotplatform/api/node_modules/botmaster-messenger/node_modules/raw-body/index.js:224:16)
    at done (/Users/abi/code/github/mcbotplatform/api/node_modules/botmaster-messenger/node_modules/raw-body/index.js:213:7)
    at IncomingMessage.onEnd (/Users/abi/code/github/mcbotplatform/api/node_modules/botmaster-messenger/node_modules/raw-body/index.js:273:7)
    at emitNone (events.js:106:13)
    at IncomingMessage.emit (events.js:208:7)
    at endReadableNT (_stream_readable.js:1064:12)
    at _combinedTickCallback (internal/process/next_tick.js:138:11)
    at process._tickDomainCallback (internal/process/next_tick.js:218:9)

Now, I know how to fix this access token issue. But, the problem is that I am not able to capture this error in my code. Seems like the error message is not coming to my incoming middleware or main botmaster file (where we configure all the channels), and it is getting resolved in the botmaster/botmaster-messenger only.

I've also tried to capture error using these event listeners. but still no luck.

botmaster.on('listening', (message) => {
  console.log(message);
});

botmaster.on('error', (bot, err) => {
  console.log(bot.type);
  console.log(err.stack);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions