twilio / twilio-node

Node.js helper library
MIT License
1.37k stars 495 forks source link

Twilio crashed nodejs on errors 'Uncaught Exception' #983

Open wasims1 opened 7 months ago

wasims1 commented 7 months ago

Issue Summary

For some design thinking beyond my understanding, someone decided to throw 'Uncaught exception' when twilio encounters an error. This is causing Nodejs apps to shutdown (and restart) when that happens which is quite impractical in production. This issue is well documented however i see no resolution so far. Here are some of the tickets and discussion about it:

https://github.com/twilio/twilio-node/issues/949 https://stackoverflow.com/questions/54175579/how-to-handle-twilio-errors-that-crash-nodejs

Steps to Reproduce

  1. Run nodejs with twilio
  2. Make a call that will produce an error such as: /Conversations/undefined/Participants
  3. Your nodejs will crash and have to restart

Is there any timeline for fixing this terrible issue?

bradleyy1012 commented 7 months ago

Yea this happens with a variety of specific api calls. Whoever designed the backend architecture for twilio should probably stop coding.

tiwarishubham635 commented 3 months ago

Hi! One such issue was resolved by #952. Is there some other case where you are facing uncaught exceptions? Please share the code samples to help us reproduce the error. Thanks!

NishikantS578 commented 2 months ago

"RestException [Error]: Invalid 'To' Phone Number" this error is also uncaught exceptions.

tiwarishubham635 commented 2 months ago

Hi @NishikantS578! Can you please share your code snippet? Thanks!

NishikantS578 commented 2 months ago
    client.messages.create({
        body: message,
        from: phone,
        to: "9234789238",
    })

Since the 'to' field does not have a valid phone number ( The phone number should include country code as well), twilio throws uncaught exception in response to that.

RestException [Error]: Invalid 'To' Phone Number:

It would be better if it did not threw uncaught exception, since that crashes server.

tiwarishubham635 commented 1 month ago

Ohh got it. We need to catch these exceptions. I have added this to our internal backlog to be prioritized. +1s/reactions on this issue (and comments) and PRs will bump it higher up the backlog.