[superlog] Warn on stalled insights worker jobs#515
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR replaces #501 with a clean implementation on top of
Confidence Score: 4/5Safe to merge — the only call-site change is the log level and the addition of an inferred job name; no job processing or data path is affected. The logic change is tiny and well-covered by tests. The one thing worth keeping an eye on is that the repeat:insights-dispatch: / repeat:insights-maintenance: prefix strings are BullMQ internals; if BullMQ ever alters that format the inference will silently degrade to unknown rather than producing an error. All three files are straightforward; worker-events.ts lines 17-21 are the only place where an assumption about BullMQ's internal key format is encoded. Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant BullMQ as BullMQ Worker
participant WK as worker.ts
participant WE as worker-events.ts
participant EL as evlog-insights
BullMQ->>WK: stalled(jobId)
WK->>WE: buildInsightsStalledJobEvent(jobId)
WE->>WE: inferInsightsStalledJobName(jobId)
Note over WE: Prefix match on jobId:<br/>insights-website-* → insights-generate-website<br/>insights-rollup-* → insights-rollup<br/>repeat:insights-dispatch:* → insights-dispatch<br/>repeat:insights-maintenance:* → insights-maintenance<br/>else → unknown
WE-->>WK: "{ job_id, job_name }"
WK->>EL: "emitInsightsEvent("warn", "worker.job_stalled", { job_id, job_name })"
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant BullMQ as BullMQ Worker
participant WK as worker.ts
participant WE as worker-events.ts
participant EL as evlog-insights
BullMQ->>WK: stalled(jobId)
WK->>WE: buildInsightsStalledJobEvent(jobId)
WE->>WE: inferInsightsStalledJobName(jobId)
Note over WE: Prefix match on jobId:<br/>insights-website-* → insights-generate-website<br/>insights-rollup-* → insights-rollup<br/>repeat:insights-dispatch:* → insights-dispatch<br/>repeat:insights-maintenance:* → insights-maintenance<br/>else → unknown
WE-->>WK: "{ job_id, job_name }"
WK->>EL: "emitInsightsEvent("warn", "worker.job_stalled", { job_id, job_name })"
Reviews (1): Last reviewed commit: "fix(insights): warn on stalled worker jo..." | Re-trigger Greptile |
| if (jobId.startsWith("repeat:insights-dispatch:")) { | ||
| return INSIGHTS_DISPATCH_JOB_NAME; | ||
| } | ||
| if (jobId.startsWith("repeat:insights-maintenance:")) { | ||
| return INSIGHTS_MAINTENANCE_JOB_NAME; |
There was a problem hiding this comment.
Inference tied to BullMQ's internal repeat-key format
The repeat:insights-dispatch: and repeat:insights-maintenance: prefix checks rely on BullMQ's undocumented internal key format for upsertJobScheduler-generated jobs. BullMQ v5 changed the scheduler API significantly, and a future version could alter this prefix without a breaking-change notice. If the format changes, stalled scheduler jobs will silently fall through to "unknown" rather than surfacing the correct job name — degrading the usefulness of the telemetry without any error to alert the team.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Clean replacement for #501, based on staging.\n\nWhat changed:\n- Downgrades insights worker stalled-job telemetry from ERROR to WARN.\n- Adds deterministic stalled job-name inference for website, rollup, dispatch, and maintenance jobs.\n- Preserves the existing transient Redis worker error WARN helper from #482.\n\nVerification:\n- cd apps/insights && bun test src/worker-events.test.ts src/worker-errors.test.ts\n- bunx ultracite check apps/insights/src/worker.ts apps/insights/src/worker-events.ts apps/insights/src/worker-events.test.ts\n- bun run lint\n- bun run check-types\n- bun run test
Summary by cubic
Warn instead of error on stalled insights worker jobs and attach a deterministic job_name based on the job ID. This reduces noisy alerts and makes stalled events easier to triage.
inferInsightsStalledJobNameand an event builder to map website, rollup, dispatch, and maintenance IDs from@databuddy/redis.Written for commit 6aa7ed7. Summary will update on new commits.