Skip to content

[BE-40] Add Stale Jobs Detector for surfacing stuck async processing tasks #979

Description

@devwums

Problem

@nestjs/schedule is installed but never used. Documents can get stuck in processing states if async jobs silently fail, and there is no scheduled task to surface or resolve them.

Proposed Solution

Create backend/cntr/stale-jobs-detector.job.ts exporting StaleJobEntry interface ({ entityId: string, entityType: 'BOOKING' | 'PAYMENT', status: string, stuckSinceHours: number }), and detectStaleJobs(entities: Array<{ id: string, type: string, status: string, updatedAt: Date }>, staleThresholdHours = 2, now?: Date): StaleJobEntry[]. Returns entries stuck in non-terminal statuses for longer than the threshold. All implementation must live inside backend/cntr/.

Acceptance Criteria

  • File at backend/cntr/stale-jobs-detector.job.ts
  • Non-terminal statuses treated as potentially stale: PENDING, PROCESSING, ANALYZING
  • stuckSinceHours computed from now - updatedAt
  • Completed/cancelled statuses are never returned
  • Accepts optional now: Date for testability
  • Unit test at backend/cntr/stale-jobs-detector.job.spec.ts

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions