Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Uncatchable throws on botbuilder-adapter-webex registerWebhookSubscription Functions #2217

@punithk

Description

@punithk

We were using botbuilder-adapter-webex and I see there was an issue where we change or added wrong tokens from Webex the application crashes. There was no way to catch the error as the throw error was after asynchronous operation and that could not be caught by try catch.

What we tried was:

const adapter = new WebexAdapter({
     access_token: process.env.ACCESS_TOKEN, // access token from https://developer.webex.com
     public_address: process.env.PUBLIC_ADDRESS,  // public url of this app https://myapp.com/
     secret: process.env.SECRET // webhook validation secret - you can define this yourself
});

adapter.registerWebhookSubscription('/api/messages'); // <- Code crashes here and try catch does not help when tokens are wrong
adapter.getIdentity();

What we tried was:

const adapter = new WebexAdapter({
     access_token: process.env.ACCESS_TOKEN, // access token from https://developer.webex.com
     public_address: process.env.PUBLIC_ADDRESS,  // public url of this app https://myapp.com/
     secret: process.env.SECRET // webhook validation secret - you can define this yourself
});
try{
    adapter.registerWebhookSubscription('/api/messages'); // <- This does not help
    adapter.getIdentity();
}
catch(err){
    console.error(err);
}

What was the result you received?

Code crashed even with try catch.

What did you expect?

The error should be catchable on try catch or .then().catch(); so that it can be managed. If tokens expire or are changed it would simply crash the server which should not be the behavior instead it should be handled to gracefully let user decide.

Probable reason its happening:

Both registerWebhookSubscription and registerAdaptiveCardWebhookSubscription are not returning promise and throwing error asynchronously, wrapping it with a promise should fix it.

Context:

  • Botkit version: any version
  • Messaging Platform: Any
  • Node version: Any
  • Os: Any
  • Any other relevant information:
    Try to wrap and provide solution as a pull request

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions