mastra-ai/mastra · error · Error

Stored sleepUntil "${entry.id}" missing literal date.

Error message

Stored sleepUntil "${entry.id}" missing literal date.

What it means

For a stored `sleepUntil` entry, rehydration requires a literal date as a Date instance or a string; Date objects can't survive JSON serialization, so stored graphs normally carry strings. If entry.date is neither (undefined, number, null), applyGraphEntry throws this error.

Source

Thrown at packages/core/src/workflows/dynamic/rehydrate.ts:110

    case 'mapping': {
      const cfg = parseMapConfig(entry.mapConfig, entry.id);
      const live = rehydrateMapConfig(cfg, mastra);
      wf.map(live, { id: entry.id });
      return;
    }
    case 'sleep': {
      if (typeof entry.duration !== 'number') {
        throw new Error(`Stored sleep "${entry.id}" missing literal duration.`);
      }
      // Push directly (not wf.sleep()) so the stored step id survives the
      // round-trip — the builder generates a fresh random id per call.
      const live: StepFlowEntry = { type: 'sleep', id: entry.id, duration: entry.duration };
      wf.__pushStepFlowEntry(live, live);
      return;
    }
    case 'sleepUntil': {
      if (!(entry.date instanceof Date) && typeof entry.date !== 'string') {
        throw new Error(`Stored sleepUntil "${entry.id}" missing literal date.`);
      }
      const date = entry.date instanceof Date ? entry.date : new Date(entry.date);
      if (Number.isNaN(date.getTime())) {
        throw new Error(`Stored sleepUntil "${entry.id}" has an unparseable date: ${String(entry.date)}`);
      }
      const live: StepFlowEntry = { type: 'sleepUntil', id: entry.id, date };
      wf.__pushStepFlowEntry(live, { type: 'sleepUntil', id: entry.id, date });
      return;
    }
    case 'parallel': {
      const live: StepFlowEntry = {
        type: 'parallel',
        steps: entry.steps.map(s => rehydrateSingleEntry(s, mastra, schemaOpts)),
      };
      wf.__pushStepFlowEntry(live, entry);
      return;
    }
    case 'foreach': {

View on GitHub (pinned to 75dd419e61)

Solutions

  1. Store/pass the date as an ISO 8601 string (or a live Date when constructing in memory).
  2. Fix the corrupted stored entry for the named step id.
  3. Update custom storage serialization to persist sleepUntil dates as strings.

Example fix

// before
{ type: 'sleepUntil', id: 'wait', date: 1735689600000 }
// after
{ type: 'sleepUntil', id: 'wait', date: '2025-01-01T00:00:00.000Z' }
Defensive patterns

Strategy: validation

Validate before calling

function assertSleepUntilEntry(entry) {
  if (entry.type === 'sleepUntil' && !(entry.date instanceof Date) && typeof entry.date !== 'string') {
    throw new TypeError(`sleepUntil step "${entry.id}" must have a Date or ISO string date`);
  }
}

Type guard

function hasValidSleepUntilDate(e: { date?: unknown }): e is { date: Date | string } {
  return e.date instanceof Date || typeof e.date === 'string';
}

Try / catch

try {
  const wf = await rehydrateWorkflow(stored, mastra);
} catch (e) {
  if (e instanceof Error && e.message.includes('missing literal date')) {
    // repair the stored entry to carry an ISO string date and retry
  }
  throw e;
}

Prevention

When it happens

Trigger: A stored workflow graph has `{ type: 'sleepUntil', id, date: 1735689600000 }` (number), missing date, or null — typically because serialization dropped the Date, or a hand-built definition used a timestamp number instead of an ISO string.

Common situations: Custom storage adapters serializing dates to numbers; hand-authored definitions passing epoch millis; migrations converting date strings to Date objects prematurely and then failing storage round-trips.

Related errors


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