Skip to content

fix: require() crash in scheduler + unused imports (CodeQL #337, #338)#66

Merged
Sam-Aitech merged 1 commit into
mainfrom
fix/consolidated-notifications-require-and-unused-imports
Jun 25, 2026
Merged

fix: require() crash in scheduler + unused imports (CodeQL #337, #338)#66
Sam-Aitech merged 1 commit into
mainfrom
fix/consolidated-notifications-require-and-unused-imports

Conversation

@Sam-Aitech

Copy link
Copy Markdown
Owner

Why

Reviewing the consolidated-notification-engine work surfaced one runtime bug and the two open CodeQL findings.

What

scheduler.tsrunConsolidatedNotificationJob was loaded via require() inside the cron callback. This project is ESM (package.json type: module); require is undefined there. Since it's inside the callback, not at module load, it wouldn't throw at boot — it throws the first time the cron actually fires (07:00/19:00 UTC), so it'd ship clean and fail silently in production until someone checked logs. Replaced with a top-level import, and added the missing .catch() to match every other job registration in this file.

sponsorMonitorJob.ts — the legacy inline notification dispatch was removed in a36da0f, which left notifyUsersOfEvent, getNotificationQueue, and NOTIFICATION_JOB with no call sites. This is exactly what CodeQL #337 and #338 are flagging. Removed both; processQueuedEngineEvents (same import line) is still used elsewhere and is kept.

Verification

  • grep confirms zero remaining references to the three removed names
  • npx tsc --noEmit — the one error present (web-push missing types) reproduces identically on unmodified main; confirmed pre-existing, unrelated to this change
  • npx vitest run — 331/331 (pre-commit hook)

Closes CodeQL #337, #338 (will auto-resolve once this merges and a scan runs).

scheduler.ts called runConsolidatedNotificationJob via require() inside
a cron callback. The server is built as ESM (package.json type: module),
require is undefined here, and the cron only fires at 07:00/19:00 UTC —
so it would throw at the worst possible time instead of at boot.

sponsorMonitorJob.ts: removing the legacy inline notification dispatch
(a36da0f) left notifyUsersOfEvent, getNotificationQueue, and
NOTIFICATION_JOB unused — flagged by CodeQL (#337, #338).
@Sam-Aitech
Sam-Aitech merged commit d720cf0 into main Jun 25, 2026
13 checks passed
@sonarqubecloud

Copy link
Copy Markdown

@Sam-Aitech
Sam-Aitech deleted the fix/consolidated-notifications-require-and-unused-imports branch June 27, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant