ruvnet/ruflo · error

RvfEventLog not initialized. Call initialize() first.

Error message

RvfEventLog not initialized. Call initialize() first.

What it means

RvfEventLog gates its operations behind ensureInitialized(), which throws unless initialize() has run to completion in this instance. append(), replay, and snapshot helpers all require the log file and in-memory indexes to be set up first. Reusing a log after shutdown, skipping initialize(), or ignoring an initialize() failure all surface here.

Source

Thrown at v3/@claude-flow/shared/src/events/rvf-event-log.ts:424

    // version tracker
    const current = this.aggregateVersions.get(event.aggregateId) ?? 0;
    if (event.version > current) {
      this.aggregateVersions.set(event.aggregateId, event.version);
    }
  }

  /** Ensure parent directory exists for a file path. */
  private ensureDirectory(filePath: string): void {
    const dir = dirname(filePath);
    if (!existsSync(dir)) {
      mkdirSync(dir, { recursive: true });
    }
  }

  /** Guard that throws if initialize() has not been called. */
  private ensureInitialized(): void {
    if (!this.initialized) {
      throw new Error('RvfEventLog not initialized. Call initialize() first.');
    }
  }
}

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. await log.initialize() once at startup before any append/replay, and surface its errors
  2. If initialization failed, fix the underlying filesystem issue (directory permissions, disk full) and re-initialize
  3. Create a new RvfEventLog instance after shutdown instead of reusing the old one

Example fix

// before
const log = new RvfEventLog({ logPath });
log.append(event); // throws: not initialized

// after
const log = new RvfEventLog({ logPath });
await log.initialize();
await log.append(event);
Defensive patterns

Strategy: validation

Validate before calling

const log = new RvfEventLog({ logPath });
await log.initialize();
await log.append(event);

Try / catch

try {
  await log.append(event);
} catch (e) {
  if (e instanceof Error && e.message.includes('not initialized')) {
    await log.initialize();
    await log.append(event);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling log.append(event) without awaiting log.initialize(); fire-and-forget initialization racing the first append; calling operations after the log was shut down; initialize() failing on an unwritable directory while the error was swallowed.

Common situations: Missing await in startup wiring; background workers starting before the log finishes initialization; tests constructing RvfEventLog directly without the init step.

Related errors


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/489e9bd3c5139b79. Report an issue: GitHub.