Unhandled error event for document get() on Error: 14 UNAVAILABLE: Name resolution failed for target firestore.googleapis.com:443

See original GitHub issue

Environment details

  • OS: macOS Catalina 10.15.4
  • Node.js version: 14.4
  • npm version: 6.14.4
  • @google-cloud/firestore version: 3.7.1

Steps to reproduce

Problematic method: DocumentSnapshot get()

This error happens occasionally (I am assuming due to instance network outage or dns errors) but it is unable to be handled properly as the error does not seem to be propagated back up due to it being unhandled from the firestore package as intended for document get() method. For comparison, the set() method handles it properly so the error can be caught in our api.

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: 14 UNAVAILABLE: Name resolution failed for target firestore.googleapis.com:443
    at Object.callErrorFromStatus (/api/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client.js:327:49)
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:303:181)
    at Http2CallStream.outputStatus (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:114:27)
    at Http2CallStream.maybeOutputStatus (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:153:22)
    at Http2CallStream.endCall (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:140:18)
    at Http2CallStream.cancelWithStatus (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:441:14)
    at ChannelImplementation.tryPick (/api/node_modules/@grpc/grpc-js/build/src/channel.js:214:32)
    at ChannelImplementation._startCallStream (/api/node_modules/@grpc/grpc-js/build/src/channel.js:244:14)
    at Http2CallStream.start (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:418:22)
Emitted 'error' event on ClientReadableStreamImpl instance at:
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client.js:327:28)
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:303:181)
    [... lines matching original stack trace ...]
    at Http2CallStream.start (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:418:22)
    at BaseStreamingInterceptingCall.start (/api/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:275:19) {
  code: 14,
  details: 'Name resolution failed for target firestore.googleapis.com:443',
  metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}

To easily reproduce the error, network access was disabled on the machine to cause the dns error. Then tested it with a simple api:


const { Firestore } = require('@google-cloud/firestore');
const client = new Firestore();

function get() {
  const doc = client.doc('test_user/user.person1');

  doc.get().then((res) => {
    console.log('get_result', res);
  }).catch((err) => {
    console.error('get_error', err);
  });
}

function set() {
  const doc = client.doc('test_user/user.person2');

  doc.set({ name: 'humanName' }).then((res) => {
    console.log('set_result', res);
  }).catch((err) => {
    console.error('set_error', err);
  });
}

set(); // error caught properly
get(); // error not caught properly

which would produce this:

set_error Error: 14 UNAVAILABLE: Name resolution failed for target firestore.googleapis.com:443
    at Object.callErrorFromStatus (/api/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client.js:174:52)
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:340:141)
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:303:181)
    at Http2CallStream.outputStatus (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:114:27)
    at Http2CallStream.maybeOutputStatus (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:153:22)
    at Http2CallStream.endCall (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:140:18)
    at Http2CallStream.cancelWithStatus (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:441:14)
    at ChannelImplementation.tryPick (/api/node_modules/@grpc/grpc-js/build/src/channel.js:214:32)
    at Object.updateState (/api/node_modules/@grpc/grpc-js/build/src/channel.js:82:26) {
  code: 14,
  details: 'Name resolution failed for target firestore.googleapis.com:443',
  metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}

events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: 14 UNAVAILABLE: Name resolution failed for target firestore.googleapis.com:443
    at Object.callErrorFromStatus (/api/node_modules/@grpc/grpc-js/build/src/call.js:30:26)
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client.js:327:49)
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:303:181)
    at Http2CallStream.outputStatus (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:114:27)
    at Http2CallStream.maybeOutputStatus (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:153:22)
    at Http2CallStream.endCall (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:140:18)
    at Http2CallStream.cancelWithStatus (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:441:14)
    at ChannelImplementation.tryPick (/api/node_modules/@grpc/grpc-js/build/src/channel.js:214:32)
    at ChannelImplementation._startCallStream (/api/node_modules/@grpc/grpc-js/build/src/channel.js:244:14)
    at Http2CallStream.start (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:418:22)
Emitted 'error' event on ClientReadableStreamImpl instance at:
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client.js:327:28)
    at Object.onReceiveStatus (/api/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:303:181)
    [... lines matching original stack trace ...]
    at Http2CallStream.start (/api/node_modules/@grpc/grpc-js/build/src/call-stream.js:418:22)
    at BaseStreamingInterceptingCall.start (/api/node_modules/@grpc/grpc-js/build/src/client-interceptors.js:275:19) {
  code: 14,
  details: 'Name resolution failed for target firestore.googleapis.com:443',
  metadata: Metadata { internalRepr: Map(0) {}, options: {} }
}

I think it would be better if this error produced from get() can be handled similarly to set().

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
laljikanjareeyacommented, Sep 11, 2020

@yonbh I am able to reproduce the issue in 3.7.1 get() does not handle the error properly.

I have run demo that you have given above with Version 4.0.0 and above it works fine, It handles the error properly.

Closing this issue feel free to reopen the issue.

Update: Please clean node_modues and package-lock.json and re-install version 4.0.0 or higher don’t need to change @grpc/grpc-js dependency it should work.

1reaction
schmidt-sebastiancommented, Aug 7, 2020

@yonbh Sorry for being so slow here 😕 I am not able to reproduce this. For me, the catch handler is invoked (after a lot of backoff) and the uncaughtException is not called. I was however not able to generate the same error that you were seeing, but tried with various other errors (such as specifying an invalid host). I’ll ponder more about this, but for now I don’t see an obvious problem in our code that we could fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

how do I handle Name resolution failed for target firestore ...
Emitted 'error' event on ClientReadableStreamImpl instance at: This means that the error is being thrown because the stream is emitting an error ......
Read more >
Firestore: Cannot get Quickstart to work · Issue #7679 - GitHub
I followed the quickstart guide for Firestore in Python but I couldn't get it to run as ... UNAVAILABLE details = "Name resolution...
Read more >
DNS resolution failed for service: googleads.googleapis.com ...
I'm getting the following error when I'm calling Google Ads API. Status(StatusCode=\"Unavailable\", Detail=\"DNS resolution failed for ...
Read more >
FirebaseFirestoreException.Code - Google
Some document that we attempted to create already exists. ... For example, a successful response from a server could have been delayed long...
Read more >
Errors | Cloud APIs - Google Cloud
This chapter provides an overview of the error model for Google APIs. It also provides general guidance to developers on how to properly...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found