@remit/smtp-worker 0.0.23 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
SmtpConnectionError,
|
|
16
16
|
type sendMail,
|
|
17
17
|
} from "@remit/smtp-service";
|
|
18
|
+
import { attemptBudget } from "@remit/sqs-client/attempt-budget";
|
|
18
19
|
import type { SendMessageEvent } from "../events.js";
|
|
19
20
|
import { writeEngagementCounters } from "./engagement-counters.js";
|
|
20
21
|
import {
|
|
@@ -133,24 +134,9 @@ const SENDABLE_STATUSES: ReadonlySet<OutboxMessageItem["status"]> = new Set([
|
|
|
133
134
|
OutboxMessageStatus.sending,
|
|
134
135
|
]);
|
|
135
136
|
|
|
136
|
-
/**
|
|
137
|
-
* Fallback when `SEND_MESSAGE_MAX_ATTEMPTS` is unset (local dev, unit tests).
|
|
138
|
-
* Matches `remit-smtp`'s `maxReceiveCount` (`deploy/vps/queues.json`), same
|
|
139
|
-
* pattern as `MESSAGE_MOVE_MAX_ATTEMPTS` / `FLAG_PUSH_MAX_ATTEMPTS` in
|
|
140
|
-
* imap-worker.
|
|
141
|
-
*/
|
|
142
|
-
const DEFAULT_SEND_MESSAGE_MAX_ATTEMPTS = 3;
|
|
143
|
-
|
|
144
137
|
export const getSendMessageMaxAttempts = (
|
|
145
138
|
processEnv: NodeJS.ProcessEnv = process.env,
|
|
146
|
-
): number =>
|
|
147
|
-
const raw = processEnv.SEND_MESSAGE_MAX_ATTEMPTS;
|
|
148
|
-
if (!raw) return DEFAULT_SEND_MESSAGE_MAX_ATTEMPTS;
|
|
149
|
-
const parsed = Number.parseInt(raw, 10);
|
|
150
|
-
return Number.isFinite(parsed) && parsed > 0
|
|
151
|
-
? parsed
|
|
152
|
-
: DEFAULT_SEND_MESSAGE_MAX_ATTEMPTS;
|
|
153
|
-
};
|
|
139
|
+
): number => attemptBudget("SEND_MESSAGE_MAX_ATTEMPTS", 3, processEnv);
|
|
154
140
|
|
|
155
141
|
export const SEND_MESSAGE_MAX_ATTEMPTS = getSendMessageMaxAttempts();
|
|
156
142
|
|