{"record":{"id":"a024249b3470dc87","repo":"clockworklabs/SpacetimeDB","slug":"brotli-compression-is-not-supported-by-the-runtime","errorCode":null,"errorMessage":"Brotli compression is not supported by the runtime. Please choose a different compression method.","messagePattern":"Brotli compression is not supported by the runtime\\. Please choose a different compression method\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"crates/bindings-typescript/src/sdk/db_connection_builder.ts","lineNumber":101,"sourceCode":"    return this;\n  }\n\n  withWSFn(createWSFn: WebSocketFactory): this {\n    this.#createWSFn = createWSFn;\n    return this;\n  }\n\n  /**\n   * Set the compression algorithm to use for the connection.\n   *\n   * @param compression The compression algorithm to use for the connection.\n   */\n  withCompression(compression: 'gzip' | 'brotli' | 'none'): this {\n    if (compression === 'brotli') {\n      try {\n        new DecompressionStream('brotli' as CompressionFormat);\n      } catch (e) {\n        throw new TypeError(\n          `Brotli compression is not supported by the runtime. Please choose a different compression method.`,\n          { cause: e }\n        );\n      }\n    }\n    this.#compression = compression;\n    return this;\n  }\n\n  /**\n   * Sets the connection to operate in light mode.\n   *\n   * Light mode is a mode that reduces the amount of data sent over the network.\n   *\n   * @param lightMode The light mode for the connection.\n   */\n  withLightMode(lightMode: boolean): this {\n    this.#lightMode = lightMode;","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/bindings-typescript/src/sdk/db_connection_builder.ts#L83-L119","documentation":"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.","triggerScenarios":"Calling .withCompression('brotli') on a connection builder in a runtime whose DecompressionStream rejects 'brotli': Firefox, many Node.js versions, and several edge/worker runtimes.","commonSituations":"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.","solutions":["Use 'gzip' or 'none' instead of 'brotli'","Feature-detect before choosing: try { new DecompressionStream('brotli') } catch { /* pick 'gzip' */ }","Pin the compression choice to the deployment target's documented supported formats"],"exampleFix":"// before\nDbConnection.builder().withCompression('brotli'); // throws in Firefox/Node\n\n// after\nDbConnection.builder().withCompression(supportsBrotli() ? 'brotli' : 'gzip');","handlingStrategy":"validation","validationCode":"function pickCompression(): 'brotli' | 'gzip' {\n  try {\n    new DecompressionStream('brotli' as CompressionFormat);\n    return 'brotli';\n  } catch {\n    return 'gzip';\n  }\n}\nDbConnection.builder().withCompression(pickCompression());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Do not hardcode 'brotli' if the code also runs in Node/Firefox/workers","Feature-detect DecompressionStream format support per target runtime","Test the compression choice in the actual deployment runtime, not just your dev browser"],"tags":["compression","runtime-compat","websocket","typescript"],"backgroundTag":"unsupported-compression-format","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}