grpc / grpc-dart

The Dart language implementation of gRPC.
https://pub.dev/packages/grpc
Apache License 2.0
861 stars 271 forks source link

Implement fetch based transport #549

Open jbrownsw opened 2 years ago

jbrownsw commented 2 years ago

This is essentially to resolve issue #511. It's designed to be very similar to the existing xhr transport, but with my own FetchHttpRequest to replace the HttpRequest type. I was a little lazy on the events so they differ a bit, but I could change them to match those used by xhr to make them even more similar. I could also remove some of the code duplication and the transport stream and connection could be shared with only FetchHttpRequest or HttpRequest being the difference and that could be passed in as a function or a generic type parameter. Finally the last thing I wasn't sure of is if you would want this as a complete replacement for xhr or if you'd rather them coexist so people can switch between them etc. So web_channel.dart will need to be updated based on what route you want to go there.

I'm already using this as a drop in replacement for our app and haven't noticed any differences other than the memory growth for streams disappearing.

linux-foundation-easycla[bot] commented 2 years ago

CLA Signed

The committers listed above are authorized under a signed CLA.

jbrownsw commented 2 years ago

I created an issue for the dart SDK with my last change (5a8818b): https://github.com/dart-lang/sdk/issues/49399

listepo commented 10 months ago

Hi @jbrownsw, do you think webfetch could help resolve the issue?

matt-deboer commented 7 months ago

@jbrownsw I just tested this branch today (had to add one no-op implementation for the updated main branch) and it seems to work well in debug and release mode. Perhaps your original issues have been since resolved? Or maybe I'm not hitting the repro condition?

For me, it makes my jpeg video stream actually usable in grpc-web, so would love to see it merged :)

jbrownsw commented 7 months ago

I don't work at the company that I developed this for so I can't test it, but perhaps @gawmanarnar can get someone to confirm.