clockworklabs/SpacetimeDB · error · TypeError

Brotli compression is not supported by the runtime. Please…

Error message

Brotli compression is not supported by the runtime. Please choose a different compression method.

What it means

DbConnectionBuilder.withCompression('brotli') feature-detects by constructing new DecompressionStream('brotli'). Brotli is not part of the baseline WHATWG CompressionStream formats (gzip/deflate/deflate-raw), so runtimes without a brotli extension make the constructor throw, and the builder rethrows it as a TypeError with the original error attached as cause.

Solutions

  1. Use 'gzip' or 'none' instead of 'brotli'
  2. Feature-detect before choosing: try { new DecompressionStream('brotli') } catch { /* pick 'gzip' */ }
  3. Pin the compression choice to the deployment target's documented supported formats

Example fix

// before
DbConnection.builder().withCompression('brotli'); // throws in Firefox/Node

// after
DbConnection.builder().withCompression(supportsBrotli() ? 'brotli' : 'gzip');
Defensive patterns

Strategy: validation

Validate before calling

function pickCompression(): 'brotli' | 'gzip' {
  try {
    new DecompressionStream('brotli' as CompressionFormat);
    return 'brotli';
  } catch {
    return 'gzip';
  }
}
DbConnection.builder().withCompression(pickCompression());

Prevention

When it happens

Trigger: Calling .withCompression('brotli') on a connection builder in a runtime whose DecompressionStream rejects 'brotli': Firefox, many Node.js versions, and several edge/worker runtimes.

Common situations: Code developed in a Chromium browser (which supports brotli decompression) then executed in Node, Firefox, or a worker; assuming web-platform parity across runtimes; defaulting to brotli because the server prefers it.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20). Data as JSON: /api/errors/a024249b3470dc87. Report an issue: GitHub.

Appendix: source

Thrown at crates/bindings-typescript/src/sdk/db_connection_builder.ts:101

    return this;
  }

  withWSFn(createWSFn: WebSocketFactory): this {
    this.#createWSFn = createWSFn;
    return this;
  }

  /**
   * Set the compression algorithm to use for the connection.
   *
   * @param compression The compression algorithm to use for the connection.
   */
  withCompression(compression: 'gzip' | 'brotli' | 'none'): this {
    if (compression === 'brotli') {
      try {
        new DecompressionStream('brotli' as CompressionFormat);
      } catch (e) {
        throw new TypeError(
          `Brotli compression is not supported by the runtime. Please choose a different compression method.`,
          { cause: e }
        );
      }
    }
    this.#compression = compression;
    return this;
  }

  /**
   * Sets the connection to operate in light mode.
   *
   * Light mode is a mode that reduces the amount of data sent over the network.
   *
   * @param lightMode The light mode for the connection.
   */
  withLightMode(lightMode: boolean): this {
    this.#lightMode = lightMode;

View on GitHub (pinned to 6dee26c6ef)