fix(smtp): close the raw email stream when a relay does not send it (#423)
relayEmail opens a read stream on the .eml file for every relay, and only client.send() ever consumed it. When the auto-relay rules left no recipients, or the outgoing server failed the send (e.g. rejected a recipient), the stream was never read or destroyed and its file descriptor stayed open. Destroy it on the early return and in the finally block; after a successful send it is already fully read, so that is a no-op.
This commit is contained in:
1 parent
27e7633a30
commit
5479067fab
3 files changed
+78
-2
No files matched your search
@@ -100,6 +100,7 @@ export class RelayClient {
|
||||
|
||||
// Fail silently if no recipients
|
||||
if (recipients.length === 0) {
|
||||
emailStream.destroy()
|
||||
return {
|
||||
success: false,
|
||||
message: 'Email had no recipients after filtering',
|
||||
@@ -132,6 +133,9 @@ export class RelayClient {
|
||||
error: err,
|
||||
}
|
||||
} finally {
|
||||
// The stream holds an open file descriptor until it is fully read or
|
||||
// destroyed; on a failed relay it was never (fully) piped to the server.
|
||||
emailStream.destroy()
|
||||
await this.disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user