firebase / firebase/firebase-js-sdk

[Web] Support Grpc configuration in Web Client SDK

Open
#8,048 5 comments 1 reaction 1 assignee Claimed by @cherylEnkidu View on GitHub
api: firestore feature request
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

Description

### Operating System

Debian GNU/Linux 11 (bullseye) Linux 6.1.21-v8+

### Browser Version

Node 16.20.0

### Firebase SDK Version

10.8.1

### Firebase SDK Product:

Auth, Firestore

### Describe your project's tooling

esbuild ^0.19.5

### Describe the problem

The Firebase JavaScript SDK when running in a Node.js environment (may also affect others) takes in excess of 15 minutes to detect a silently broken network connection (e.g. NAT entry erased or traffic blocking being applied) preventing Firestore listeners on the device from receiving updates and writes from reaching the server.

[history.txt](https://github.com/firebase/firebase-js-sdk/files/14447498/history.txt)
[grpc-logs.txt](https://github.com/firebase/firebase-js-sdk/files/14447507/grpc-logs.txt)

### Steps and code to reproduce issue

Recommended: Set environment flags `GRPC_VERBOSITY=debug GRPC_TRACE=all` for better observation of gRPC activity.

Launch Node program with at least one firestore listener.

Block internet traffic at the router or apply firewall rules blocking internet traffic to/from your device or over the specific connection to firestore backend to simulate silently killed network connection.

Observe how long it takes for a message such as the following to appear:
```
[2024-02-29T09:50:17.531Z] @firebase/firestore: Firestore (10.3.1): GrpcConnection RPC 'Listen' stream 0x6ba5ef16 error. Code: 14 Message: 14 UNAVAILABLE: read ETIMEDOUT
[2024-02-29T09:50:17.531Z] @firebase/firestore: Firestore (10.3.1): GrpcConnection RPC 'Listen' stream 0x40aaf17c error. Code: 14 Message: 14 UNAVAILABLE: read ECONNRESET

Or from gRPC:
D 2024-02-29T10:50:17.497Z | subchannel_call | [7] Node error event: message=read ECONNRESET code=ECONNRESET errno=Unknown system error -104 syscall=read
```

It appears, based on tcpdump, that the Firestore client doesn't even send keepalives to the backend server. The server sends keepalives every 45 seconds, but the client is either unable to or not configured to monitor for a certain number of missed keepalives before trying to reconnect.

In my test case, it took 32 minutes before the ECONNRESET was triggered by Node leading gRPC to start trying to reconnect.

Once the block is removed and the device is allowed to reconnect, even once the gRPC keepalives started flowing again, my Firestore listeners never started working again.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.