feat: never exit workflow

This commit is contained in:
Nevo David 2026-01-06 21:13:51 +07:00
parent 012a347ed6
commit 0f4c39ede0
1 changed files with 2 additions and 5 deletions

View File

@ -35,10 +35,7 @@ export async function sendEmailWorkflow({
// Process emails with rate limiting
while (true) {
// Wait until there's an email in the queue or timeout after 1 hour of inactivity
const waitForQueue = await condition(() => queue.length > 0, '1 hour');
if (!waitForQueue) {
return;
}
await condition(() => queue.length > 0);
try {
const email = queue.shift()!;
@ -53,7 +50,7 @@ export async function sendEmailWorkflow({
await sleep(RATE_LIMIT_MS);
if (processedThisRun >= 100) {
if (processedThisRun >= 30) {
return await continueAsNew({ queue });
}
}