Skip to content

feat!: Add timeout parameter to SendGrid API clients#1125

Open
pellepim wants to merge 1 commit intosendgrid:mainfrom
pellepim:add-http-timeout-support
Open

feat!: Add timeout parameter to SendGrid API clients#1125
pellepim wants to merge 1 commit intosendgrid:mainfrom
pellepim:add-http-timeout-support

Conversation

@pellepim
Copy link

Fixes

HTTP requests made by this library (e.g., to send emails via the APIs) have no timeout by default. If a network issue causes a request to hang, the calling process blocks indefinitely.

This PR adds a timeout parameter (defaulting to 30 seconds) to SendGridAPIClient and TwilioEmailAPIClient. The underlying python_http_client already supports this. Callers can override the default or disable it by passing timeout=None.

Technically, this is a breaking change. Code that previously hung silently will now raise the new SendGridTimeoutError exception after timeout seconds. Anyone relying on infinite wait (intentionally or not) will see new exceptions.

That said, it's hard to argue the previous behavior was correct. A process hanging forever isn't really "working." But strictly by semver rules, changing the default from no timeout to 30 seconds is a breaking change since it alters existing behavior.

Checklist

  • I acknowledge that all my contributions will be made under the project's license
  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the Contribution Guidelines
    and my PR follows them
  • I have titled the PR appropriately
  • I have updated my branch with the main branch
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation about the functionality in the appropriate .md file
  • I have added inline documentation to the code I modified

If you have questions, please file a support ticket.

Default to a 30 second HTTP timeout to prevent hung processes.
The timeout is passed through to python_http_client which already
supports it. Callers can override or disable (via None) as needed.
Timeouts via send() raise SendGridTimeoutError for clean handling.
@pellepim pellepim force-pushed the add-http-timeout-support branch from 1bfb2ed to 5c889c4 Compare March 20, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant