mastra-ai/mastra · error

Platform Linear reconcile interval must be a positive number

Error message

Platform Linear reconcile interval must be a positive number.

What it means

The Platform Linear event worker constructor validates that the state reconciliation interval (`config.reconcileIntervalMs`) is a finite number greater than 0. The default (`DEFAULT_RECONCILE_INTERVAL_MS`) applies only when the option is omitted, so this error means an explicit value of 0, a negative number, NaN, or Infinity was supplied. It throws in the constructor so a bad reconcile schedule is caught at boot, not at first reconcile.

Source

Thrown at mastracode/factory/src/integrations/platform/linear/event-worker.ts:160

  #settings: PlatformLinearEventWorkerSettings = { version: 1, workspaces: {} };

  constructor(config: PlatformLinearEventWorkerConfig) {
    super();
    this.#client = config.client;
    this.#linear = config.linear;
    this.#storage = config.storage;
    this.#projects = config.projects;
    this.#workItems = config.workItems;
    this.#ingestFactoryIssue = config.ingestFactoryIssue;
    this.#reconcileFactoryState = config.reconcileFactoryState;
    this.#pollEventsEnabled = config.pollEventsEnabled ?? true;
    this.#intervalMs = config.intervalMs ?? DEFAULT_POLL_INTERVAL_MS;
    this.#reconcileIntervalMs = config.reconcileIntervalMs ?? DEFAULT_RECONCILE_INTERVAL_MS;
    if (!Number.isFinite(this.#intervalMs) || this.#intervalMs <= 0) {
      throw new Error('Platform Linear event polling interval must be a positive number.');
    }
    if (!Number.isFinite(this.#reconcileIntervalMs) || this.#reconcileIntervalMs <= 0) {
      throw new Error('Platform Linear reconcile interval must be a positive number.');
    }
    this.#leaseTtlMs = Math.max(MIN_LEASE_TTL_MS, this.#intervalMs * 3);
    this.#now = config.now ?? Date.now;
  }

  async init(deps: WorkerDeps): Promise<void> {
    await super.init(deps);
    this.#leaseProvider = getLeaseProvider(deps.pubsub);
  }

  async start(): Promise<void> {
    if (this.#running) return;
    if (!this.deps) throw new Error('PlatformLinearEventWorker: call init() before start()');

    this.#startedAt = this.#now() - 1;
    this.#settings = normalizeSettings(await this.#storage.settings.get(CURSOR_ORG_ID, CURSOR_USER_ID));
    this.#running = true;
    this.deps.logger.info('Platform Linear event polling started', {

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Set `reconcileIntervalMs` to a finite positive number of milliseconds (e.g. 300000).
  2. Delete the `reconcileIntervalMs` option to fall back to DEFAULT_RECONCILE_INTERVAL_MS.
  3. Fix the underlying env var so it is blank/absent (use ?? undefined, not Number('')) or a valid positive integer.
  4. Sanitize before passing: only assign the value when `Number.isFinite(v) && v > 0`.

Example fix

// before
new LinearEventWorker({ reconcileIntervalMs: Number(process.env.LINEAR_RECONCILE_MS) });
// after
const raw = process.env.LINEAR_RECONCILE_MS?.trim();
const parsed = raw ? Number(raw) : undefined;
new LinearEventWorker({ reconcileIntervalMs: parsed !== undefined && Number.isSafeInteger(parsed) && parsed > 0 ? parsed : undefined });
Defensive patterns

Strategy: validation

Validate before calling

const raw = process.env.LINEAR_RECONCILE_MS?.trim();
const reconcileIntervalMs = raw === undefined || raw === '' ? undefined : Number(raw);
if (reconcileIntervalMs !== undefined && !(Number.isFinite(reconcileIntervalMs) && reconcileIntervalMs > 0)) {
  throw new Error(`LINEAR_RECONCILE_MS must be a positive number, got: ${raw}`);
}

Type guard

function isPositiveFiniteNumber(v: unknown): v is number {
  return typeof v === 'number' && Number.isFinite(v) && v > 0;
}

Prevention

When it happens

Trigger: Constructing the Linear event worker with `reconcileIntervalMs: 0`, a negative value, NaN, or Infinity — e.g. `reconcileIntervalMs: Number(process.env.LINEAR_RECONCILE_MS)` where the env var is empty string (NaN) or '0'.

Common situations: Empty or unset env var coerced to NaN via Number(''); ops setting the value to 0 to 'turn off' reconciliation; a unit-test fixture passing 0 and expecting the default.

Related errors


AI-assisted analysis of mastra-ai/mastra@75dd419e61 (2026-08-30). Data as JSON: /api/errors/6cd18b1269f1d183. Report an issue: GitHub.