grpc-web icon indicating copy to clipboard operation
grpc-web copied to clipboard

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

Open mike-lerch opened this issue 4 years ago • 1 comments

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.

mike-lerch avatar Jan 18 '22 21:01 mike-lerch

Hi! Thanks for the report! :)

However, i'm not quite able to reproduce the issue following your example in safari Version 15.2 (17612.3.6.1.6).

May i ask what Safari version are you using?

Also, i'm curious if you've tested on other browsers too? Is it possible that this is a Safari bug rather than grpc-web bug?

Thanks! :)

sampajano avatar Jan 29 '22 06:01 sampajano