nodejs-bigquery icon indicating copy to clipboard operation
nodejs-bigquery copied to clipboard

setting GOOGLE_APPLICATION_CREDENTIALS break bigquery

Open flapili opened this issue 2 years ago • 0 comments

Hi,

settings GOOGLE_APPLICATION_CREDENTIALS totally break bigquery

Environment details

  • OS: macos somona
  • Node.js version: 18.18.2 via nvm
  • npm version: pnpm8.10.2
  • @google-cloud/bigquery version: 7.3.0

Steps to reproduce

import process from "node:process";
import { BigQuery } from "@google-cloud/bigquery"

const path = "./project-id-123456789.json"

async function listDatasets(client) {
    const [datasets] = await client.getDatasets();
    console.log(`Datasets:\n${datasets.map((dataset) => ` - ${dataset.id}`).join("\n")}\n`);
}
// work, return the datasets
await listDatasets(new BigQuery({
    projectId: "foobar",
    keyFile: path,
}))

// doesn't work, but doesn't throw any error, just return empty list
process.env.GOOGLE_APPLICATION_CREDENTIALS = path
await listDatasets(new BigQuery())

// doesn't work anymore 
await listDatasets(new BigQuery({
    projectId: "foobar",
    keyFile: path,
}))

flapili avatar Nov 09 '23 16:11 flapili