2.5 KiB
2.5 KiB
Execution Plan - Fix Auth Scheduler Env Vars
The goal of this plan is to fix the issue where the authentication scheduler fails to read environment variables in the SvelteKit application and to increase the scheduler frequency to every 5 minutes.
User Stories
Story 1: Fix Environment Variable Access and Update Frequency Logic
As a developer I want the scheduler to use SvelteKit's idiomatic environment variable handling and support minute-level intervals So that the configuration is correctly loaded and I can set a more frequent schedule.
Acceptance Criteria:
src/lib/server/scheduler.tsimportsenvfrom$env/dynamic/private.getConfig()usesenv.AUTH_SCHEDULER_ENABLEDandenv.AUTH_SCHEDULER_INTERVAL_MINUTES.SchedulerConfiginterface usesintervalMinutesinstead ofintervalHours.startScheduler()calculates the interval in milliseconds based on minutes.src/hooks.server.tscomments are updated to reflect the new environment variable names.
Technical Notes:
- SvelteKit does not automatically populate
process.envwith.envfile values in all contexts. Using$env/dynamic/privateensures access to runtime environment variables. - Default
intervalMinutesshould be set to a reasonable value (e.g., 720 for 12 hours) if not provided, but the user specifically requested 5 minutes configuration.
Story 2: Update Configuration
As a user I want my local environment configuration to reflect the new frequency settings So that the scheduler runs every 5 minutes as desired.
Acceptance Criteria:
.env.localis updated to includeAUTH_SCHEDULER_INTERVAL_MINUTES=5..env.localno longer containsAUTH_SCHEDULER_INTERVAL_HOURS.
Implementation Steps
Step 1: Refactor Scheduler Logic
- File:
src/lib/server/scheduler.ts - Action:
- Import
envfrom$env/dynamic/private. - Update
getConfigfunction to read fromenv. - Rename
intervalHourstointervalMinutesinSchedulerConfigandgetConfig. - Update
startSchedulerto useintervalMinutes * 60 * 1000. - Update log messages to display "min" instead of "h".
- Import
Step 2: Update Hooks Documentation
- File:
src/hooks.server.ts - Action: Update the JSDoc comment for
initto documentAUTH_SCHEDULER_INTERVAL_MINUTES.
Step 3: Update Local Configuration
- File:
.env.local - Action:
- Replace
AUTH_SCHEDULER_INTERVAL_HOURS=1(or whatever value) withAUTH_SCHEDULER_INTERVAL_MINUTES=5.
- Replace