sissonb
sissonb

Reputation: 3780

Automatically reconnecting using `firebase serve` on localhost

I am hosting a firebase project on my computer using firebase serve. When my internet goes out I get the error below and the program exits. Is there an --option that enables auto reconnect or someway to catch the error manually and reconnect? I want the application to keep attempting to connect until my internet comes back online.

>        throw er; // Unhandled 'error' event
>        ^
> 
>  Error: 14 UNAVAILABLE: Name resolution failed for target dns:firestore.googleapis.com:443
>      at Object.callErrorFromStatus (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\call.js:30:26)
>      at Object.onReceiveStatus (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\client.js:328:49)
>      at Object.onReceiveStatus (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:304:181)
>      at Http2CallStream.outputStatus (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\call-stream.js:116:74)
>      at Http2CallStream.maybeOutputStatus (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\call-stream.js:155:22)
>      at Http2CallStream.endCall (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\call-stream.js:141:18)
>      at Http2CallStream.cancelWithStatus (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\call-stream.js:450:14)
>      at ChannelImplementation.tryPick (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\channel.js:237:32)
>      at ChannelImplementation._startCallStream (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\channel.js:267:14)
>      at Http2CallStream.start (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\call-stream.js:428:22)
>  Emitted 'error' event on ClientReadableStreamImpl instance at:
>      at Object.onReceiveStatus (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\client.js:328:28)
>      at Object.onReceiveStatus (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:304:181)
>      [... lines matching original stack trace ...]
>      at Http2CallStream.start (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\call-stream.js:428:22)
>      at BaseStreamingInterceptingCall.start (C:\Users\Tower\IdeaProjects\team-up-server\functions\node_modules\@grpc\grpc-js\build\src\client-interceptors.js:276:1
9) {
>    code: 14,
>    details: 'Name resolution failed for target dns:firestore.googleapis.com:443',
>    metadata: Metadata { internalRepr: Map {}, options: {} }
>  }

Upvotes: 1

Views: 300

Answers (1)

ultraGentle
ultraGentle

Reputation: 6319

firebase serve is deprecated.

Try firebase emulators:start; I haven't suffered any on/off/online problems using it.

Docs: https://firebase.google.com/docs/rules/emulator-setup


BUT, note in the error message, that the error is related to a Google API call you're making.

If you're calling an online API instead of an emulated one, your app itself will need to be able to be set up to retry or handle failed calls.

Some aspects of firebase can indeed be emulated locally; again, see the docs linked above.

Upvotes: 1

Related Questions