From 30e775a8092abde7d5f2c2d98b4135cc9b82838a Mon Sep 17 00:00:00 2001 From: Hermes Coding Manager Date: Wed, 29 Jul 2026 08:30:10 -0400 Subject: [PATCH] fix(worker): use CJS-compatible rrule import for Node ESM runtime The rrule v2.8.1 package's main field points to a CJS bundle. When the worker runs under Node 22 with "type": "module", Node resolves to the CJS main which only has a default export. The previous 'import { RRule } from rrule' worked during typecheck (TypeScript uses the .d.ts) but crashed at runtime: SyntaxError: The requested module 'rrule' does not provide an export named 'RRule' Use namespace-default import + destructure to handle both CJS and ESM at runtime while preserving the static RRule reference. Verified with node --input-type=module that RRule.fromString works correctly. This was a deploy blocker: docker compose up kept restarting the worker. --- worker/index.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/worker/index.ts b/worker/index.ts index 753987c..370a362 100644 --- a/worker/index.ts +++ b/worker/index.ts @@ -1,7 +1,8 @@ import { db, jobs, webhooks, webhookDeliveries, scheduledJobs, tasks, habits, habitCompletions } from '@project-e/db'; import { and, eq, lte, isNull, sql } from 'drizzle-orm'; import { createHmac } from 'node:crypto'; -import { RRule } from 'rrule'; +import rrule from 'rrule'; +const { RRule } = rrule; const POLL_INTERVAL_BASE = 5000; // 5 seconds base const POLL_INTERVAL_MAX = 60000; // 60 seconds max