Closed
Description
Wasm support is now stable since flutter 3.22 published, i got UNAVAILABLE error while testing my web app with wasm.
Version of the grpc-dart packages used: v3.2.4 and grpc/grpc-dart master branch.
Repro steps
- Create a grpc channel using
GrpcOrGrpcWebClientChannel.toSeparateEndpoints
, write some request code. - Build:
flutter build web --wasm
. - To run a Flutter app that has been compiled to Wasm, follow Support for WebAssembly (Wasm).
Expected result: The request successfully sent as canvaskit mode does.
Actual result:
gRPC Error (code: 14, codeName: UNAVAILABLE, message: Error connecting: Unsupported operation: SecurityContext constructor, details: null, rawResponse: null, trailers: {})
Details
This error could be caused by two points:
- Wrong package imported in
grpc_or_grpcweb.dart
. Because of wasm has no html package, conditional import recognized wasm as non-web platform. - Once correct platform recognized,
xhr_transport.dart
will be used to transport data, which uses html package, but "dart:html is being replaced with package:web. Package maintainers should migrate to package:web as soon as possible to be compatible with Wasm. Read the Migrate to package:web page for guidance."
I tried to fix it in https://github.com/minoic/grpc-dart, it worked in my case but more test should be performed later.