Repository navigation
fix(api): stop the account-health sweep timing out every hour - #217
Merged
Merged
Conversation
Co-authored-by: polylane[bot] <277585245+polylane[bot]@users.noreply.github.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
The hourly account-health sweep has timed out on every run since a deploy on 28 October, so customers stopped receiving SES health checks. Its memory peaked at the function's 256 MB limit in that deploy, starving it of CPU and pushing a three-minute sweep past the ten-minute timeout. After this change it loads notification code only when it notifies and has room to finish.
Why this fix
CloudWatch shows the sweep's maximum duration stepping from 156-211 s to the 600 s timeout at the 28 October deploy, while peak memory moved from 194 MB to the 256 MB ceiling on an unchanged configuration. That deploy connected the notification code to the SES client and renderer, and the sweep loaded it on every cold start. Loading it lazily and raising memory to 1024 MB restores headroom and quadruples CPU, so the sweep finishes inside its timeout. The heavier notify path is covered by the extra memory, and the sweep's completion log will confirm recovery.
Out of scope
Production impact: Only the account-health cron changes; other cron jobs keep their config
wraps-production-AccountHealthHandlerFunction-bcxerthsis the only function this diff changes: its Maximum Duration was 156-211 s for a week and then 600000 ms on every run from 2026-10-28T05:00Z, withMax Memory Usedat 255-256 MB against a 256 MB configuration. The edited worker file is bundled only into that function, and only that job'smemoryvalue changes ininfra/cron.ts.AuditLogCleanup,BroadcastReaper,EventFeedStaleness,MessageSendCleanup,NotificationDeliveries,WorkflowReaper,MarketplaceEventsqueue and DLQ,Workflowqueue and DLQ,Batchqueue and DLQ) keep their declared configuration; I read theirErrorsmetric for the alarm window and all were zero.ApiHandlerFunctionis invoked by API Gateway and reaches Neon, Sentry and app.wraps.dev. It does not import the account-health worker, and its single 30 s timeout at 16:05:53Z predates this diff.Affected resources:
arn:aws:lambda:us-east-1:905130073023:function:wraps-production-AccountHealthHandlerFunction-bcxerths.Checked and not affected:
arn:aws:lambda:us-east-1:905130073023:function:wraps-production-ApiHandlerFunction-szkssafu,arn:aws:lambda:us-east-1:905130073023:function:MarketplaceEventsQueueSubscriberWdnrfwFunctionFunction-kbbwcxkn,arn:aws:lambda:us-east-1:905130073023:function:pr-MarketplaceEventsDlqSubscriberMdosonFunctionFunction-bbehwxns,arn:aws:lambda:us-east-1:905130073023:function:productio-WorkflowQueueSubscriberMnahuuFunctionFunction-sskcosms,arn:aws:lambda:us-east-1:905130073023:function:production-WorkflowDlqSubscriberBbrurmFunctionFunction-ndksofav,arn:aws:lambda:us-east-1:905130073023:function:w-production-BatchQueueSubscriberEwchhwFunctionFunction-caerssmd,arn:aws:lambda:us-east-1:905130073023:function:wra-production-BatchDlqSubscriberXmtfhdFunctionFunction-sbssczbc,arn:aws:lambda:us-east-1:905130073023:function:wraps-production-AuditLogCleanupHandlerFunction-xscaudmf,arn:aws:lambda:us-east-1:905130073023:function:wraps-production-BroadcastReaperHandlerFunction-sdfnrbux,arn:aws:lambda:us-east-1:905130073023:function:wraps-production-EventFeedStalenessHandlerFunction-kwxacmcz,arn:aws:lambda:us-east-1:905130073023:function:wraps-production-MessageSendCleanupHandlerFunction-vnszhmta,arn:aws:lambda:us-east-1:905130073023:function:wraps-production-NotificationDeliveriesHandlerFunction-bcffmcch,arn:aws:lambda:us-east-1:905130073023:function:wraps-production-WorkflowReaperHandlerFunction-knutfdmz.Observability
/aws/lambda/wraps-production-AccountHealthHandlerFunction-bcbtnuto: the hourly[account-health] Sweep completeline withaccountsTotal/checkedCountis the signal that the sweep finished.AWS/Lambda Duration(Maximum) andErrorsfor the same function: Duration should return from 600000 ms to a few minutes and the hourly error datapoints should stop.Status: timeoutandMax Memory Used; both are existing signals, unchanged by this diff.Polylane assessed this pull request at
4141c71.Causal chain
3 files changed (+14/-3)
apps/api/src/workers/account-health.ts: modified, +6/-1infra/cron.ts: modified, +6/-1infra/selfhost.config.ts: modified, +2/-1Generated by Polylane. You can ask follow-ups by mentioning @polylane in a comment.