http icon indicating copy to clipboard operation
http copied to clipboard

Flutter build web failing due to EventStreamProviders

Open rnp0728 opened this issue 2 years ago • 6 comments

(editor update: see below - we've reverted the 2.4.2 publish of this package).


While running flutter build web the following error comes up, until yesterday the builds are working properly. The new update on web_socket_channel:2.4.2 affected this error. We are not using this package directly but some of the packages are dependent on it.

ERROR LOGS :

../../../../.pub-cache/hosted/pub.dev/web_socket_channel-2.4.2/lib/src/web_helpers.dart:10:32:
Error: The getter 'EventStreamProviders' isn't defined for the class 'WebSocket'.
 - 'WebSocket' is from 'package:web/src/dom/websockets.dart' ('../../../../.pub-cache/hosted/pub.dev/web-0.3.0/lib/src/dom/websockets.dart').
  Stream<Event> get onOpenX => EventStreamProviders.openEvent.forTarget(this);
                               ^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/web_socket_channel-2.4.2/lib/src/web_helpers.dart:12:7:
Error: The getter 'EventStreamProviders' isn't defined for the class 'WebSocket'.
 - 'WebSocket' is from 'package:web/src/dom/websockets.dart' ('../../../../.pub-cache/hosted/pub.dev/web-0.3.0/lib/src/dom/websockets.dart').
      EventStreamProviders.messageEvent.forTarget(this);
      ^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/web_socket_channel-2.4.2/lib/src/web_helpers.dart:14:7:
Error: The getter 'EventStreamProviders' isn't defined for the class 'WebSocket'.
 - 'WebSocket' is from 'package:web/src/dom/websockets.dart' ('../../../../.pub-cache/hosted/pub.dev/web-0.3.0/lib/src/dom/websockets.dart').
      EventStreamProviders.closeEvent.forTarget(this);
      ^^^^^^^^^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/web_socket_channel-2.4.2/lib/src/web_helpers.dart:16:7:
Error: The getter 'EventStreamProviders' isn't defined for the class 'WebSocket'.
 - 'WebSocket' is from 'package:web/src/dom/websockets.dart' ('../../../../.pub-cache/hosted/pub.dev/web-0.3.0/lib/src/dom/websockets.dart').
      EventStreamProviders.errorEventSourceEvent.forTarget(this);
      ^^^^^^^^^^^^^^^^^^^^

rnp0728 avatar Jan 05 '24 07:01 rnp0728

Same here

crimsonsuv avatar Jan 05 '24 08:01 crimsonsuv

Palliative solution: dependency_overrides: web_socket_channel: 2.4.0

https://github.com/dart-lang/web_socket_channel/issues/316

ambitencourt avatar Jan 05 '24 11:01 ambitencourt

Palliative solution: dependency_overrides: web_socket_channel: 2.4.0

dart-lang/web_socket_channel#316

Good!

GabrielCairesDev avatar Jan 05 '24 13:01 GabrielCairesDev

Hi - these most recent issues were likely caused by the release of 2.4.2, which adjusted the dep on package:web in ways that weren't compatible. We're retracted that release - people who have it pinned explicitly will still see it, but it won't be visible to new version solves.

Also, it looks porting this package to use package:web was (unintentionally) a breaking API change - some of the API types exposed from the package are different. We'll track work to address that in a separate issue, but we may revert the 2.4.x range of this package back to using dart:html, and publishing a new 3.0.0 version of this package that's based on package:web.

devoncarew avatar Jan 05 '24 18:01 devoncarew

dart-lang/http#1655 becomes relevant again because 2.4.3 is once-again reliant on pkg:web 0.4.0 or higher, and Flutter has 0.3.0 pinned. Flutter still won't be able to use 2.4.3.

NotTsunami avatar Jan 08 '24 19:01 NotTsunami

This is the same situation for other packages that Flutter pins however. You need to use dependencies that are compatible with the versions that Flutter was built with. For package:web, that's:

  • stable - pinned web to 0.3.0
  • beta - pinned web to 0.4.0
  • main - the pin's been removed; the few uses of package:web were in-lined into the framework

devoncarew avatar Jan 08 '24 20:01 devoncarew