@google/genai 1.39.0 → 1.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11608,7 +11608,7 @@ const CONTENT_TYPE_HEADER = 'Content-Type';
11608
11608
  const SERVER_TIMEOUT_HEADER = 'X-Server-Timeout';
11609
11609
  const USER_AGENT_HEADER = 'User-Agent';
11610
11610
  const GOOGLE_API_CLIENT_HEADER = 'x-goog-api-client';
11611
- const SDK_VERSION = '1.39.0'; // x-release-please-version
11611
+ const SDK_VERSION = '1.40.0'; // x-release-please-version
11612
11612
  const LIBRARY_LABEL = `google-genai-sdk/${SDK_VERSION}`;
11613
11613
  const VERTEX_AI_API_DEFAULT_VERSION = 'v1beta1';
11614
11614
  const GOOGLE_AI_API_DEFAULT_VERSION = 'v1beta';
@@ -17381,6 +17381,11 @@ async function defaultParseResponse(client, props) {
17381
17381
  const mediaType = (_a = contentType === null || contentType === void 0 ? void 0 : contentType.split(';')[0]) === null || _a === void 0 ? void 0 : _a.trim();
17382
17382
  const isJSON = (mediaType === null || mediaType === void 0 ? void 0 : mediaType.includes('application/json')) || (mediaType === null || mediaType === void 0 ? void 0 : mediaType.endsWith('+json'));
17383
17383
  if (isJSON) {
17384
+ const contentLength = response.headers.get('content-length');
17385
+ if (contentLength === '0') {
17386
+ // if there is no content we can't do anything
17387
+ return undefined;
17388
+ }
17384
17389
  const json = await response.json();
17385
17390
  return json;
17386
17391
  }
@@ -17840,9 +17845,10 @@ class BaseGeminiNextGenAPIClient {
17840
17845
  }
17841
17846
  async fetchWithTimeout(url, init, ms, controller) {
17842
17847
  const _b = init || {}, { signal, method } = _b, options = __rest(_b, ["signal", "method"]);
17848
+ const abort = controller.abort.bind(controller);
17843
17849
  if (signal)
17844
- signal.addEventListener('abort', () => controller.abort());
17845
- const timeout = setTimeout(() => controller.abort(), ms);
17850
+ signal.addEventListener('abort', abort, { once: true });
17851
+ const timeout = setTimeout(abort, ms);
17846
17852
  const isReadableBody = (globalThis.ReadableStream && options.body instanceof globalThis.ReadableStream) ||
17847
17853
  (typeof options.body === 'object' && options.body !== null && Symbol.asyncIterator in options.body);
17848
17854
  const fetchOptions = Object.assign(Object.assign(Object.assign({ signal: controller.signal }, (isReadableBody ? { duplex: 'half' } : {})), { method: 'GET' }), options);