clockworklabs/SpacetimeDB · error · Error

Module code was generated with an incompatible version of th

Error message

Module code was generated with an incompatible version of the spacetimedb cli (${incompatibleVersion}). Update the cli version to at least ${_MINIMUM_CLI_VERSION.toString()} and regenerate the bindings. You can upgrade to the latest cli version by running: spacetime version upgrade

What it means

ensureMinimumVersionOrThrow runs during DbConnection.builder().build() and checks the generated module metadata versionInfo.cliVersion. This branch fires when the value is undefined: the bindings were generated by a spacetimedb CLI older than 1.4.0, which did not emit the module information this SDK depends on, so the SDK refuses to connect. The interpolated version in the message renders as 'undefined'.

Source

Thrown at crates/bindings-typescript/src/sdk/version.ts:123

    const preRelease = match[4]
      ? match[4].split('.').map(id => (isNaN(Number(id)) ? id : Number(id)))
      : null;
    const buildInfo = match[5] || null;

    return new SemanticVersion(major, minor, patch, preRelease, buildInfo);
  }
}

// The SDK depends on some module information that was not generated before this version.
export const _MINIMUM_CLI_VERSION: SemanticVersion = new SemanticVersion(
  1,
  4,
  0
);

export function ensureMinimumVersionOrThrow(versionString?: string): void {
  if (versionString === undefined) {
    throw new Error(versionErrorMessage(versionString));
  }
  const version = SemanticVersion.parseVersionString(versionString);
  if (version.compare(_MINIMUM_CLI_VERSION) < 0) {
    throw new Error(versionErrorMessage(versionString));
  }
}

function versionErrorMessage(incompatibleVersion?: string): string {
  return `Module code was generated with an incompatible version of the spacetimedb cli (${incompatibleVersion}). Update the cli version to at least ${_MINIMUM_CLI_VERSION.toString()} and regenerate the bindings. You can upgrade to the latest cli version by running: spacetime version upgrade`;
}

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Upgrade the CLI (>= 1.4.0): `spacetime version upgrade`, then regenerate the TypeScript bindings
  2. Delete stale generated binding files/directories and re-run generation from scratch
  3. Pin the CLI version in CI so every regeneration uses a compatible toolchain

Example fix

# before (bindings generated with old cli)
spacetime generate --lang typescript --out-dir src/module

# after
spacetime version upgrade
spacetime generate --lang typescript --out-dir src/module
Defensive patterns

Strategy: validation

Validate before calling

import { SemanticVersion, _MINIMUM_CLI_VERSION } from './version';
const cliVersion = remoteModule.versionInfo?.cliVersion;
if (!cliVersion) {
  throw new Error('Bindings are pre-1.4.0 (no cliVersion). Regenerate with spacetimedb CLI >= 1.4.0');
}
if (SemanticVersion.parseVersionString(cliVersion).compare(_MINIMUM_CLI_VERSION) < 0) {
  throw new Error(`Bindings from CLI ${cliVersion}; need >= ${_MINIMUM_CLI_VERSION.toString()}`);
}

Type guard

function bindingsHaveVersionInfo(mod: { versionInfo?: { cliVersion?: string } }): boolean {
  return typeof mod.versionInfo?.cliVersion === 'string';
}

Prevention

When it happens

Trigger: Calling .build() with TypeScript bindings generated by spacetimedb CLI < 1.4.0 (no versionInfo in the generated remote module), or with a hand-rolled RemoteModule that omits versionInfo.

Common situations: Upgraded the SDK package but not the CLI; CI or a teammate regenerating bindings with an old CLI from PATH; cached/committed generated bindings from before the upgrade.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/658815a6b8da6fe9. Report an issue: GitHub.