Repository navigation
notify/email: honour the context when dialing with implicit TLS - #5690
vignesh2027 wants to merge 1 commit into
Conversation
The plain SMTP path dials with DialContext, but the implicit TLS path used tls.Dial, which has no timeout and ignores the context. A smarthost that accepts the TCP connection but never completes the TLS handshake blocked the notification with no limit. Use tls.Dialer.DialContext so both the dial and the handshake stop when the notification context is done. Signed-off-by: vigneshwar <applemacbook6sep2004@gmail.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Context-aware implicit-TLS dialing notify/email/email.go, notify/email/email_test.go |
Email.Notify uses tls.Dialer.DialContext with the notification context for implicit-TLS connections. The test checks cancellation during a stalled handshake and requires the call to return within five seconds. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Merge Risk: 
Minimal · up to 4afd4
-
Implicit-TLS notification dialing now honors cancellation, and no actionable merge risk is identified.
Pre-merge checks: 
5
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Pull Request Checklist
Please check all the applicable boxes.
benchstatto compare benchmarksThe email notifier connects with
net.Dialer.DialContextwhen it uses plain SMTP or STARTTLS, but withtls.Dialwhen implicit TLS is used (port 465 orforce_implicit_tls: true).tls.Dialhas no timeout and does not look at the context.If the smarthost accepts the TCP connection but never finishes the TLS handshake,
Notifystays blocked even after the notification context is done. The existingTestEmailNotifyWithDoneContextcovers this for the plain path only.This change uses
tls.Dialer.DialContext, so the dial and the handshake both stop when the context ends. The new test starts a listener that accepts connections and never writes, then callsNotifywith a 100ms context timeout. On main it is still blocked after 5 seconds. With the fix it returnsestablish TLS connection to server: ...right after the timeout.Which user-facing changes does this PR introduce?