Skip to content

Migrate off legacy JS/HTML apis #715

Closed
@minoic

Description

@minoic

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

  1. Create a grpc channel using GrpcOrGrpcWebClientChannel.toSeparateEndpoints, write some request code.
  2. Build: flutter build web --wasm.
  3. 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:

  1. Wrong package imported in grpc_or_grpcweb.dart. Because of wasm has no html package, conditional import recognized wasm as non-web platform.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions