gax-nodejs: Misconfiguration of apiEndpoint, servicePath or port causes hang on query

Copied from original issue: https://github.com/googleapis/nodejs-datastore/issues/79

@kevinohara80
March 28, 2018 5:54 PM

Actual

Currently, when you execute a query with an invalid apiEndpoint, servicePath or port, the query executes but does not call the callback or reject a promise. It simply hangs with no error logging. This causes blocking in application code as the guarantee of a callback and/or promise is broken.

Expected

Misconfigured clients should error. When a Datastore client is misconfigured, queries should error appropriately by returning an error in the callback and/or rejecting the promise.

Environment details

  • OS: MacOS
  • Node.js version: 8.9.1
  • npm version: 5.8.1
  • @google-cloud/datastore version: 1.4.0

Steps to reproduce

  1. Configure a Datastore client as shown below
  2. Attempt to make a query
  3. Wait for callback and/or promise. Neither callbacks nor promises are resolved.

Example code

Datastore client configuration

const datastore = new Datastore({
  servicePath: 'datastore.googleapis.com',
  port: 324 // invalid port
});

Or…

const datastore = new Datastore({
  servicePath: 'zzzzzdatastore.googleapis.com' // invalid servicePath
});

Then try executing a query…

const query = datastore.createQuery(NAMESPACE, KIND);

datastore.runQuery(query, function (err, records) {
  if (err) return reject(err);
  return resolve(records);
});

Or…

const query = datastore.createQuery(NAMESPACE, KIND);

datastore.runQuery(query)
  .then(() => console.log('ok'))
  .catch(err => console.error(err))

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 22 (16 by maintainers)

Most upvoted comments

Well, if you found this and still think it’s an issue 👍

unsetting PUBSUB_EMULATOR_HOST does resolve, but would’ve been much happier if some console message saved me 3 days 🤣

@ofrobots and the gRPC folks were having a productive conversation on how to fix this.