Skip to content

does not work in denoΒ #3712

@uriva

Description

@uriva

Please make sure you have searched for information in the following guides.

A screenshot that you have tested with "Try this API".

it works in node

Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.

the code is included

A step-by-step description of how to reproduce the issue, based on the linked reproduction.

import { google } from "npm:[email protected]";

const auth = new google.auth.GoogleAuth({
  credentials: JSON.parse(
    Deno.readTextFileSync(
      "server/src/integrations/google-products-api-key.json",
    ),
  ),
  scopes: ["https://www.googleapis.com/auth/spreadsheets"],
});

const sheets = google.sheets({ version: "v4", auth });

const range = "Sheet1!A1";

const addRow = (
  { rowData, spreadsheetId }: {
    rowData: (string | number)[];
    spreadsheetId: string;
  },
) =>
  sheets.spreadsheets.values.append({
    spreadsheetId,
    range,
    valueInputOption: "RAW",
    requestBody: { values: [rowData] },
  });

addRow({
  rowData: ["Name", "Email", "Age"],
  spreadsheetId: "1GeClrU8qxv1ccgUvgT2ZdhI8GrL_VDTytqhptJgm_IU",
}).then(() => console.log("Row added"));
error: Uncaught (in promise) Error: Invalid response body while trying to fetch https://oauth2.googleapis.com/token: Premature close
    at Gaxios._request (file:///home/uri/.cache/deno/npm/registry.npmjs.org/gaxios/7.1.1/build/cjs/src/gaxios.js:164:23)
    at Object.runMicrotasks (ext:core/01_core.js:692:26)
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:59:10)
    at runNextTicks (ext:deno_node/_next_tick.ts:76:3)
    at eventLoopTick (ext:core/01_core.js:185:21)
Caused by: FetchError: Invalid response body while trying to fetch https://oauth2.googleapis.com/token: Premature close
    at consumeBody (file:///home/uri/.cache/deno/npm/registry.npmjs.org/node-fetch/3.3.2/src/body.js:234:60)
    at Object.runMicrotasks (ext:core/01_core.js:692:26)
    at processTicksAndRejections (ext:deno_node/_next_tick.ts:59:10)
    at runNextTicks (ext:deno_node/_next_tick.ts:76:3)
    at eventLoopTick (ext:core/01_core.js:185:21)
    at async Response.text (file:///home/uri/.cache/deno/npm/registry.npmjs.org/node-fetch/3.3.2/src/body.js:158:18)
    at async Response.json (file:///home/uri/.cache/deno/npm/registry.npmjs.org/node-fetch/3.3.2/src/body.js:148:16)
    at async Gaxios._defaultAdapter (file:///home/uri/.cache/deno/npm/registry.npmjs.org/gaxios/7.1.1/build/cjs/src/gaxios.js:117:22)
    at async Gaxios._request (file:///home/uri/.cache/deno/npm/registry.npmjs.org/gaxios/7.1.1/build/cjs/src/gaxios.js:143:38)

A clear and concise description of what the bug is, and what you expected to happen.

for some reasno gaxios throws exception in deno not in node

A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **

is deno supported?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions