grpc / grpc/grpc-web

No error/end-callback triggered for streams on ERR_NETWORK_CHANGED

Open
#1,363 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

pending-clarification
Dominant language
JavaScript
Stars
9.3k
Forks
801
Avg merge
1d 7h
Merged PRs (30d)
5

Description

We are using long-running server-streams where the server pushes updates to the frontend.
If the user's network connections change (e.g. due to entering / leaving a VPN), these long-running streams immediately stop - so far so good.

The Browser shows these streams as "failed" inside the network tab:
![image](https://github.com/grpc/grpc-web/assets/2649265/c39c3091-3974-45ca-bc70-2b73e7cbafa5)

In addition to that, the console tab also shows the failed request:
![image](https://github.com/grpc/grpc-web/assets/2649265/f4a1adbd-d351-4529-938b-32c367e1f262)

Note though that the HTTP Status is 200.

**The issue:**
grpc-web does not propagate the error to our application. I'd expect both the "error" and "end"-callbacks to be triggered. Maybe even the "status"-callback.
(Or, at least, the "end"-callback). They are not.
As a consequence, these background-streams silently stop, and we can't inform the user or restart the streams.

**Simplified code example:**
```
this._alertServiceClient = new AlertServicePublicClient(/*...*/);

// ...

const req: Empty = new Empty();
this._alertStream = this._alertServiceClient.streamAlertChanges(req);

// None of these callbacks gets called if the stream stops with ERR_NETWORK_CHANGED:
this._alertStream.on('data', (response: AlertChanges) => {
console.log('DATA', status);
});
this._alertStream.on('error', (err: RpcError) => {
console.log('ERROR', err);
});
this._alertStream.on('end', () => {
console.log('END');
});
this._alertStream.on('status', (status) => {
console.log('STATUS', status);
});

this._store.dispatch(AlertChangesStarted());
```

**Setup:**
We are using Google Chrome, but it also happens for other browsers.
The backend starts with an nginX-server, that forwards all grpc-web calls to an enovy proxy. Envoy then translates to grpc and forwards to individual backend services.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the streamAlertChanges entry point and reproduce the failure by changing the network connection while a server stream is active. Trace how ERR_NETWORK_CHANGED is handled and verify that the error, end, or status callback is invoked when the stream stops.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.