From 33ba0df66202b285eb5a5634d3806bc8f133a69e Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Mon, 9 Dec 2024 13:41:37 -0800 Subject: [PATCH 1/4] ci: heap size limit reached bug --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a18caee6f2f..a0c891d5f99 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "e2e:debug": "playwright test src/e2e/ --ui", "e2e:smoke": "playwright test src/e2e/ --grep @smoke", "cron:first-data-broker-removal-fixed": "node dist/scripts/cronjobs/firstDataBrokerRemovalFixed.js", - "cron:monthly-activity-free": "node dist/scripts/cronjobs/monthlyActivityFree.js", + "cron:monthly-activity-free": "NODE_OPTIONS=--max-old-space-size=4096 node dist/scripts/cronjobs/monthlyActivityFree.js", "cron:monthly-activity-plus": "node dist/scripts/cronjobs/monthlyActivityPlus.js", "cron:breach-alerts": "node dist/scripts/cronjobs/emailBreachAlerts.js", "cron:db-delete-unverified-subscribers": "node dist/scripts/cronjobs/deleteUnverifiedSubscribers.js", From 96460030baf35192c0e1ba680a5263c8d580ed5d Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Tue, 10 Dec 2024 19:33:50 -0800 Subject: [PATCH 2/4] fix: replace promise.allsettled --- src/scripts/cronjobs/monthlyActivityFree.tsx | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/scripts/cronjobs/monthlyActivityFree.tsx b/src/scripts/cronjobs/monthlyActivityFree.tsx index 634314acac2..5ca9a50aee9 100644 --- a/src/scripts/cronjobs/monthlyActivityFree.tsx +++ b/src/scripts/cronjobs/monthlyActivityFree.tsx @@ -40,11 +40,16 @@ async function run() { .slice(0, batchSize); await initEmail(); - await Promise.allSettled( - subscribersToEmail.map((subscriber) => - sendMonthlyActivityEmail(subscriber), - ), - ); + for (const subscriber of subscribersToEmail) { + try { + await sendMonthlyActivityEmail(subscriber); + } catch (error) { + logger.error("send_monthly_activity_email_error_free", { + subscriber_id: subscriber.id, + error, + }); + } + } closeEmailPool(); console.log( From bea8bf04dc42f7d5ae2492bd7178488095b48c41 Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Tue, 10 Dec 2024 19:38:32 -0800 Subject: [PATCH 3/4] fix: more logging --- src/scripts/cronjobs/monthlyActivityFree.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/scripts/cronjobs/monthlyActivityFree.tsx b/src/scripts/cronjobs/monthlyActivityFree.tsx index 5ca9a50aee9..7a9ad235d81 100644 --- a/src/scripts/cronjobs/monthlyActivityFree.tsx +++ b/src/scripts/cronjobs/monthlyActivityFree.tsx @@ -32,6 +32,8 @@ async function run() { `Could not send monthly activity emails, because the env var MONTHLY_ACTIVITY_FREE_EMAIL_BATCH_SIZE has a non-numeric value: [${process.env.MONTHLY_ACTIVITY_EMAIL_BATCH_SIZE}].`, ); } + + logger.info(`Getting free subscribers with batch size: ${batchSize}`); const subscribersToEmail = (await getFreeSubscribersWaitingForMonthlyEmail()) .filter((subscriber) => { const assumedCountryCode = getSignupLocaleCountry(subscriber); @@ -43,9 +45,12 @@ async function run() { for (const subscriber of subscribersToEmail) { try { await sendMonthlyActivityEmail(subscriber); + logger.info("send_monthly_activity_email_free_success", { + subscriberId: subscriber.id, + }); } catch (error) { - logger.error("send_monthly_activity_email_error_free", { - subscriber_id: subscriber.id, + logger.error("send_monthly_activity_email_free_error", { + subscriberId: subscriber.id, error, }); } From 1c87696ec58d0b05b8cccf51aee75bb7d7df5f7f Mon Sep 17 00:00:00 2001 From: Joey Zhou Date: Tue, 10 Dec 2024 19:39:41 -0800 Subject: [PATCH 4/4] revert: del max heap --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a0c891d5f99..a18caee6f2f 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,7 @@ "e2e:debug": "playwright test src/e2e/ --ui", "e2e:smoke": "playwright test src/e2e/ --grep @smoke", "cron:first-data-broker-removal-fixed": "node dist/scripts/cronjobs/firstDataBrokerRemovalFixed.js", - "cron:monthly-activity-free": "NODE_OPTIONS=--max-old-space-size=4096 node dist/scripts/cronjobs/monthlyActivityFree.js", + "cron:monthly-activity-free": "node dist/scripts/cronjobs/monthlyActivityFree.js", "cron:monthly-activity-plus": "node dist/scripts/cronjobs/monthlyActivityPlus.js", "cron:breach-alerts": "node dist/scripts/cronjobs/emailBreachAlerts.js", "cron:db-delete-unverified-subscribers": "node dist/scripts/cronjobs/deleteUnverifiedSubscribers.js",