Repository navigation
Contact form: a sendmail that exits before reading it all has not sent it - #579
Merged
Merged
Conversation
…t it sendmail resolved on the child's exit code alone. A sendmail that exits 0 before reading the whole message makes two events race: the EPIPE on its stdin (rejected) and the child's close (resolved). Whichever came first decided, so a message cut short could be reported sent, and the spec "fails, rather than taking the server down, when the MTA does not read it all" failed on CI twice on 20 Oct (passing locally). Now an exit of 0 is success only when stdin was also written in full; both orders reject. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
A single-PR fix: the contact form's mail hand-off. It is not part of any spec.
The bug.
sendmailresolved on the child's exit code alone. A sendmail that exits 0 before reading the whole message makes two events race:Whichever came first decided the result, so a message cut short could be reported as sent. The spec "fails, rather than taking the server down, when the MTA does not read it all" failed on CI twice on 20 Oct (#573, #578) while passing locally.
The fix. An exit of 0 counts as success only when stdin was also written in full (
writableFinished). Both orders now reject.How far this is checked.
exit 0, reading nothing). On the old code, 3 to 14% of 1 MB sends and about half of 70 KB sends were wrongly reported sent. With this change, 0 of 104 1 MB sends were.cat >/dev/null; exit 0) resolved every time: about 3,900 sends from 0 bytes to 10 MB, with the CPU loaded too. stdin'sfinishalways came before the child'sclose.sendmail -t -ireads to the end of input, so this doesn't arise in practice.🤖 Generated with Claude Code