{"record":{"id":"9a816076d95c4d65","repo":"google/zx","slug":"blob-is-not-supported-in-this-environment-provide","errorCode":null,"errorMessage":"Blob is not supported in this environment. Provide a polyfill","messagePattern":"Blob is not supported in this environment\\. Provide a polyfill","errorType":"exception","errorClass":"Fail","httpStatus":null,"severity":"error","filePath":"src/core.ts","lineNumber":946,"sourceCode":"  get [Symbol.toStringTag](): string {\n    return 'ProcessOutput'\n  }\n\n  get ok(): boolean {\n    return !this._dto.error && this.exitCode === 0\n  }\n\n  json<T = any>(): T {\n    return JSON.parse(this.stdall)\n  }\n\n  buffer(): Buffer {\n    return Buffer.from(this.stdall)\n  }\n\n  blob(type = 'text/plain'): Blob {\n    if (!globalThis.Blob)\n      throw new Fail(\n        'Blob is not supported in this environment. Provide a polyfill'\n      )\n    return new Blob([this.buffer() as BlobPart], { type })\n  }\n\n  text(encoding: Encoding = 'utf8'): string {\n    return encoding === 'utf8'\n      ? this.toString()\n      : this.buffer().toString(encoding)\n  }\n\n  lines(delimiter?: string | RegExp): string[] {\n    return iteratorToArray(this[Symbol.iterator](delimiter))\n  }\n\n  override toString(): string {\n    return this.stdall\n  }","sourceCodeStart":928,"sourceCodeEnd":964,"githubUrl":"https://github.com/google/zx/blob/00a2c484e219c2e84bfc3a199febf7fbce2cfbf4/src/core.ts#L928-L964","documentation":"Thrown by ProcessOutput.blob() when globalThis.Blob is undefined in the current runtime. Node exposes a global Blob from v15.7+ (stable from v16.7+); older Node versions or non-Node/edge runtimes may lack it, so zx asks for a polyfill before calling blob().","triggerScenarios":"Calling `output.blob()` on Node < 16.7, or in a JS runtime/embedded engine without a Blob constructor; using a bundler configuration that strips node:buffer globals.","commonSituations":"Legacy Node in CI pipelines; embedded JS engines; stripped/minimal runtimes; older Lambda/container base images.","solutions":["Upgrade Node to >= 18 (current LTS).","Polyfill from node:buffer: `import { Blob } from 'node:buffer'; globalThis.Blob ??= Blob`.","Avoid blob() — use output.buffer() or output.text() which do not require Blob."],"exampleFix":"// before (Node < 16.7)\nconst b = output.blob()\n// after: polyfill from node:buffer\nimport { Blob } from 'node:buffer'\nglobalThis.Blob ??= Blob\nconst b = output.blob()","handlingStrategy":"type-guard","validationCode":"function ensureBlobPolyfill(): void {\n  if (typeof globalThis.Blob === 'undefined') {\n    const { Blob } = require('node:buffer')\n    globalThis.Blob = Blob\n  }\n}\n\nensureBlobPolyfill()\nconst b = output.blob()","typeGuard":"const hasBlob = (g: typeof globalThis): g is typeof globalThis & { Blob: typeof Blob } =>\n  typeof g.Blob === 'function'","tryCatchPattern":"try {\n  output.blob()\n} catch (e) {\n  if (e instanceof Fail && /Blob is not supported/.test(e.message)) {\n    // fall back to buffer()\n    return output.buffer()\n  }\n  throw e\n}","preventionTips":["Target Node >= 18 LTS where Blob is globally available.","Polyfill globalThis.Blob from node:buffer in bootstrap code for older runtimes.","Prefer output.buffer()/output.text() when you do not specifically need a Blob."],"tags":["blob","polyfill","node-version","environment"],"backgroundTag":null,"analyzedSha":"00a2c484e219c2e84bfc3a199febf7fbce2cfbf4","analyzedAt":"2026-08-13T02:11:06.305Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}