2

如何以及在哪里处理此错误并阻止我的应用程序崩溃?

$ node app.js
Server Started at port 3000
events.js:200
      throw er; // Unhandled 'error' event
      ^

Error: 14 UNAVAILABLE: Name resolution failed for target firestore.googleapis.com:443
    at Object.callErrorFromStatus (D:\food_list\node_modules\@grpc\grpc-js\build\src\call.js:30:26)
    at Object.onReceiveStatus (D:\food_list\node_modules\@grpc\grpc-js\build\src\client.js:327:49)
    at Object.onReceiveStatus (D:\food_list\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:303:181)
    at Http2CallStream.outputStatus (D:\food_list\node_modules\@grpc\grpc-js\build\src\call-stream.js:114:27)
    at Http2CallStream.maybeOutputStatus (D:\food_list\node_modules\@grpc\grpc-js\build\src\call-stream.js:153:22)
    at Http2CallStream.endCall (D:\food_list\node_modules\@grpc\grpc-js\build\src\call-stream.js:140:18)
    at Http2CallStream.cancelWithStatus (D:\food_list\node_modules\@grpc\grpc-js\build\src\call-stream.js:441:14)
    at ChannelImplementation.tryPick (D:\food_list\node_modules\@grpc\grpc-js\build\src\channel.js:214:32)
    at ChannelImplementation._startCallStream (D:\food_list\node_modules\@grpc\grpc-js\build\src\channel.js:244:14)
    at Http2CallStream.start (D:\food_list\node_modules\@grpc\grpc-js\build\src\call-stream.js:418:22)
Emitted 'error' event on ClientReadableStreamImpl instance at:
    at Object.onReceiveStatus (D:\food_list\node_modules\@grpc\grpc-js\build\src\client.js:327:28)
    at Object.onReceiveStatus (D:\food_list\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:303:181)
    [... lines matching original stack trace ...]
    at Http2CallStream.start (D:\food_list\node_modules\@grpc\grpc-js\build\src\call-stream.js:418:22)
    at BaseStreamingInterceptingCall.start (D:\food_list\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 {}, options: {} }
}

ps:当我在没有互联网的情况下运行应用程序时应用程序崩溃。

4

2 回答 2

1

这是一个 DNS 错误。DNS 是一种用于 Internet 连接的服务。您的应用程序正在尝试访问互联网,特别是 Firestore,但不能。这就是为什么会出现错误。对此没有简单的解决方法,因为您还必须对应用程序行为进行编程才能在离线时运行。

于 2021-01-26T21:01:06.613 回答
0

错误堆栈跟踪说明了这一点:

Emitted 'error' event on ClientReadableStreamImpl instance at:

这意味着错误正在被抛出,因为流正在发出错误事件并且您没有处理该事件。您可以通过调用stream.on('error', callback)正在读取的流来解决此问题。

于 2020-04-24T17:04:17.087 回答