Terminate email send on context cancellation - #41
Merged
Merged
Conversation
paskal
force-pushed
the
fix/email-send-context
branch
from
August 18, 2026 23:23
9a07066 to
8207431
Compare
Coverage Report for CI Build 32218488175Coverage increased (+0.008%) to 96.132%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Coverage Report for CI Build 32197877304Coverage decreased (-0.4%) to 96.132%Details
Uncovered ChangesNo uncovered changes found. Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
Context was checked once before the send, and the sender applied its timeout to the connection setup only, so a server accepting the connection and stalling afterwards blocked Send with no way out. SendContext of go-pkgz/email covers the whole SMTP transaction. Requires go-pkgz/email with SendContext, go.mod bump is not included as that release is not out yet.
paskal
force-pushed
the
fix/email-send-context
branch
2 times, most recently
from
August 19, 2026 05:13
71c56dc to
cc68bc8
Compare
paskal
marked this pull request as ready for review
August 19, 2026 05:36
umputun
approved these changes
Aug 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The context was checked once before the send, and the sender applies its timeout to the connection setup only, so an SMTP server which accepts the connection and stalls afterwards blocked
Sendwith no way out: no cancellation, no deadline, and the caller waiting on it.SendContext, added in go-pkgz/email v0.8.0 which master already carries, covers the greeting, the authentication, the body transfer andQUIT.Cancellation stays visible to the caller: when the context ends mid-transaction the SMTP error alone would not match
errors.Is(err, context.Canceled), so the context error is reported alongside it.The test points a sender at a server which greets and stops answering, and cancels once that server has seen the client's first command, so it always exercises the part after the connection is up. It hangs without the change.