From 960ca9b67915408f26b825886f2b6c6481a658dc Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sun, 8 Feb 2026 13:07:16 +0000 Subject: fix: treat bookmark not found as a no-op in rule engine instead of a failure (#2464) When a bookmark is deleted before the rule engine worker processes its event, the worker would throw an error, triggering failure metrics, error logging, and retries. This changes both the worker and RuleEngine.forBookmark to gracefully skip processing with an info log instead. Co-authored-by: Claude --- apps/workers/workers/ruleEngineWorker.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'apps') diff --git a/apps/workers/workers/ruleEngineWorker.ts b/apps/workers/workers/ruleEngineWorker.ts index 00e20127..ecf733cd 100644 --- a/apps/workers/workers/ruleEngineWorker.ts +++ b/apps/workers/workers/ruleEngineWorker.ts @@ -67,14 +67,21 @@ async function runRuleEngine(job: DequeuedJob) { const bookmark = await getBookmarkUserId(bookmarkId); if (!bookmark) { - throw new Error( - `[ruleEngine][${jobId}] bookmark with id ${bookmarkId} was not found`, + logger.info( + `[ruleEngine][${jobId}] bookmark with id ${bookmarkId} was not found, skipping`, ); + return; } const userId = bookmark.userId; const authedCtx = await buildImpersonatingAuthedContext(userId); const ruleEngine = await RuleEngine.forBookmark(authedCtx, bookmarkId); + if (!ruleEngine) { + logger.info( + `[ruleEngine][${jobId}] bookmark with id ${bookmarkId} was not found during rule evaluation, skipping`, + ); + return; + } const results = ( await Promise.all(events.map((event) => ruleEngine.onEvent(event))) -- cgit v1.2.3-70-g09d2