MonqueOptions
Defined in: packages/core/src/scheduler/types.ts:17
Configuration options for the Monque scheduler.
Example
Section titled “Example”Properties
Section titled “Properties”baseRetryInterval?
Section titled “baseRetryInterval?”Defined in: packages/core/src/scheduler/types.ts:41
Base interval in milliseconds for exponential backoff calculation. Actual delay = 2^failCount * baseRetryInterval
Default
Section titled “Default”collectionName?
Section titled “collectionName?”Defined in: packages/core/src/scheduler/types.ts:22
Name of the MongoDB collection for storing jobs.
Default
Section titled “Default”defaultConcurrency?
Section titled “defaultConcurrency?”Defined in: packages/core/src/scheduler/types.ts:74
Default number of concurrent jobs per worker.
Default
Section titled “Default”heartbeatInterval?
Section titled “heartbeatInterval?”Defined in: packages/core/src/scheduler/types.ts:102
Interval in milliseconds for heartbeat updates during job processing.
The scheduler periodically updates lastHeartbeat for all jobs it is processing
to indicate liveness for monitoring/debugging.
Note: stale recovery is based on lockedAt + lockTimeout, not lastHeartbeat.
Default
Section titled “Default”instanceConcurrency?
Section titled “instanceConcurrency?”Defined in: packages/core/src/scheduler/types.ts:157
Maximum number of concurrent jobs processed by this instance across all registered workers.
If reached, the scheduler will stop claiming new jobs until active jobs complete. Use this to prevent a single instance from overwhelming system resources.
Note: This is an instance-level limit. Each worker still respects its own concurrency
setting, but the total across all workers cannot exceed this limit.
Example
Section titled “Example”jobRetention?
Section titled “jobRetention?”Defined in: packages/core/src/scheduler/types.ts:115
Configuration for automatic cleanup of completed and failed jobs. If undefined, no cleanup is performed.
completed?
Section titled “completed?”Age in milliseconds after which completed jobs are deleted. Cleaned up based on ‘updatedAt’ timestamp.
failed?
Section titled “failed?”Age in milliseconds after which failed jobs are deleted. Cleaned up based on ‘updatedAt’ timestamp.
interval?
Section titled “interval?”Interval in milliseconds for running the cleanup job.
Default
Section titled “Default”lockTimeout?
Section titled “lockTimeout?”Defined in: packages/core/src/scheduler/types.ts:84
Maximum time in milliseconds a job can be in ‘processing’ status before being considered stale and eligible for recovery.
Stale recovery uses lockedAt as the source of truth; this is an absolute
“time locked” limit, not a heartbeat timeout.
Default
Section titled “Default”maxBackoffDelay?
Section titled “maxBackoffDelay?”Defined in: packages/core/src/scheduler/types.ts:50
Maximum delay in milliseconds for exponential backoff. If calculated delay exceeds this value, it will be capped.
Defaults to 24 hours to prevent unbounded delays.
Default
Section titled “Default”maxConcurrency?
Section titled “maxConcurrency?”Defined in: packages/core/src/scheduler/types.ts:164
Maximum number of concurrent jobs processed by this instance across all registered workers.
maxPayloadSize?
Section titled “maxPayloadSize?”Defined in: packages/core/src/scheduler/types.ts:186
Maximum allowed BSON byte size for job data payloads.
When set, enqueue(), now(), and schedule() validate the payload size
using BSON.calculateObjectSize() before insertion. Jobs exceeding this limit
throw PayloadTooLargeError.
When undefined, no size validation occurs.
maxRetries?
Section titled “maxRetries?”Defined in: packages/core/src/scheduler/types.ts:34
Maximum number of retry attempts before marking a job as permanently failed.
Default
Section titled “Default”pollInterval?
Section titled “pollInterval?”Defined in: packages/core/src/scheduler/types.ts:28
Interval in milliseconds between polling for new jobs.
Default
Section titled “Default”recoverStaleJobs?
Section titled “recoverStaleJobs?”Defined in: packages/core/src/scheduler/types.ts:109
Whether to recover stale processing jobs on scheduler startup. When true, jobs with lockedAt older than lockTimeout will be reset to pending.
Default
Section titled “Default”safetyPollInterval?
Section titled “safetyPollInterval?”Defined in: packages/core/src/scheduler/types.ts:212
Interval in milliseconds between safety polls when change streams are active.
When change streams are connected, the scheduler uses them as the primary
notification mechanism and only polls at this longer interval as a safety net
to catch any missed events. When change streams are unavailable, the scheduler
falls back to the standard pollInterval.
This is separate from heartbeatInterval, which updates job liveness signals.
Default
Section titled “Default”schedulerInstanceId?
Section titled “schedulerInstanceId?”Defined in: packages/core/src/scheduler/types.ts:92
Unique identifier for this scheduler instance. Used for atomic job claiming - each instance uses this ID to claim jobs. Defaults to a randomly generated UUID v4.
Default
Section titled “Default”shutdownTimeout?
Section titled “shutdownTimeout?”Defined in: packages/core/src/scheduler/types.ts:56
Timeout in milliseconds for graceful shutdown.
Default
Section titled “Default”skipIndexCreation?
Section titled “skipIndexCreation?”Defined in: packages/core/src/scheduler/types.ts:175
Skip automatic index creation during initialization.
When true, initialize() will not create MongoDB indexes. Use this in production
environments where indexes are managed externally (e.g., via migration scripts or DBA
tooling). See the production checklist for the full list of required indexes.
Default
Section titled “Default”statsCacheTtlMs?
Section titled “statsCacheTtlMs?”Defined in: packages/core/src/scheduler/types.ts:198
TTL in milliseconds for getQueueStats() result caching.
When set to a positive value, repeated getQueueStats() calls with the same filter return cached results instead of re-executing the aggregation pipeline. Each unique filter (job name) maintains its own cache entry.
Set to 0 to disable caching entirely.
Default
Section titled “Default”workerConcurrency?
Section titled “workerConcurrency?”Defined in: packages/core/src/scheduler/types.ts:66
Default number of concurrent jobs per worker.
This is the per-worker concurrency limit applied when a worker is registered
without specifying its own concurrency option.