grpc / grpc/grpc-web

Example streaming code causes "Failed to load resource" in Safari

Open
#1,188 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.3k
Forks
802
Avg merge
1d 7h
Merged PRs (30d)
5

Description

Here is the streaming example given on this project:

```
var stream = echoService.serverStreamingEcho(streamRequest, metadata);
stream.on('data', function(response) {
console.log(response.getMessage());
});
stream.on('status', function(status) {
console.log(status.code);
console.log(status.details);
console.log(status.metadata);
});
stream.on('end', function(end) {
// stream end signal
});

// to close the stream
stream.cancel()
```

if this code is used verbatim on Chrome, the console logs will happen as expected. However, in Safari, the request will fail and the browser will show an error such as `Failed to load resource: Preflight response is no successful`

It appears commenting out the last line fixes this for Safari: `// stream.cancel()`

It would be useful to rewrite this in a way that works in Safari, or make it clear that the stream will hang up immediately and not wait like it does in Chrome. The server-side errors logs are confusing as well, as Envoy will only show the TLS handshake failing and a client disconnect. The stream never starts.

Contributor guide

Open the contributing guide

Research direction

Start with the streaming example reproduced in the issue and reproduce its behavior in Safari and Chrome, focusing on the final stream.cancel() call and the preflight failure. Trace the example's surrounding documentation or entry point. Done means the example works in Safari or clearly explains the immediate hang-up behavior and its server-side error symptoms.

Written by the indexing model from the issue text.

Assessment

Tech stack
grpc, javascript
Domain
api, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.