RFC: Allow both/or configuring a shorter Twilio-side global timeout or shorter timeout for POST requests
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.4k
- Forks
- 472
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 5
Description
Issue Summary
- Twilio usually responds within a second
- We need requests to be quick because e.g. for phone number lookup we have to complete the request within 30 seconds due to Heroku router constraints
- We set the http client time out to 10 seconds which seems reasonable
- When we get an execution expired due to http client timeout on message send, it's possible that Twilio eventually processed the request.
- We don't want to send the message twice.
- It would be best if Twilio closed the connection with an error code https://www.twilio.com/docs/api/errors/20500 rather than for the http client to timeout and then we'd have to wait some amount of time to try to see if the message exists in in the logs
- Right now we need to wait maybe 26 seconds for Twilio to timeout which means we can only use the 10 second timeout if we're sure we're not making transactional requests, as per the docs: "POST requests - sending an SMS or triggering an outbound call - are not idempotent. If you get a 500 Server Error on these requests, and you retry the request, it is possible for a customer to receive multiple messages or calls from your application."
Proposal
Therefore, I'd like to request that Twilio internally to have the 26 second timeout reviewed, and possibly grant a global option within the Twilio client to reduce this timeout for an account
Regular API requests, like phone number validation, 10 seconds is fine. There's a huge unknown period of time between 10 and 30 (15 and 25 seconds) where Twilio may or may not complete a transactional request and we'd be in better shape if Twilio made that decision.
I think that having a timeout and transactional_timeout with sane defaults built in by Librarian would go a good way, even if they're opt-in.
Steps to Reproduce
- Make a POST request
- Did the execution expire?
- Make this issue
Code Snippet
twilio_client.messages.create(payload.symbolize_keys)
Exception/Log
Twilio::REST::TwilioError execution expired
Technical details:
- twilio-ruby version: 5.38.0
- ruby version: 2.6.2
- environment: Heroku
Related to twilio support ticket 4562575 as suggested by Noel Gaffney
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the twilio_client.messages.create(payload.symbolize_keys) entry point and trace how its POST request timeout is applied. Clarify the desired behavior for the global timeout versus transactional POST requests; done should be a documented, agreed configuration that addresses the timeout and duplicate-message concern.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100