dart-lang / web_socket_channel

StreamChannel wrappers for WebSockets.
https://pub.dev/packages/web_socket_channel
BSD 3-Clause "New" or "Revised" License
412 stars 107 forks source link

Simplify the web_socket_channel implementation #340

Closed brianquinlan closed 2 months ago

brianquinlan commented 3 months ago

There are two components:

  1. reimplement web_socket_channel in terms of package:web_socket
  2. remove the WebSocketChannel constructor (the only known usage is in package:shelf_web_socket).

Steps:

NotTsunami commented 3 months ago

This should actually fix the issue I outlined in https://github.com/dart-lang/web_socket_channel/issues/237#issuecomment-1971592315. Looking forward to seeing this land.

NotTsunami commented 2 months ago

Should there be a corresponding task for build_runner to get updated? It still explicitly relies on 2.x.

brianquinlan commented 2 months ago

@NotTsunami Is build_runner part of a dependency cycle with web_socket_channel? My intent was not to update every package that relies on web_socket_channel, just the ones that make web_socket_channel 3.0 unusable without the update.

bc-lee commented 2 months ago

I think build_runner is a 1p package, as well as web_socket_channel, so it should be dealt with breaking changes in web_socket_channel by updating build_runner to use the new version of web_socket_channel.

It seems that build_runner and build_daemon use web_socket_channel, but they aren't affected by the breaking change in web_socket_channel 3.0.0 in the library code.

However, build_runner's test code is affected by the breaking change of web_socket_channel 3.0.0. This code uses the removed constructor of WebSocketChannel in web_socket_channel 3.0.0.

Other than this, the following patch seems to be enough to fix the dependency issue in https://github.com/dart-lang/build.

--- a/build_daemon/pubspec.yaml
+++ b/build_daemon/pubspec.yaml
@@ -15,10 +15,10 @@ dependencies:
   path: ^1.8.0
   pool: ^1.5.0
   shelf: ^1.0.0
-  shelf_web_socket: ^1.0.0
+  shelf_web_socket: ">=1.0.0 <3.0.0"
   stream_transform: ^2.0.0
   watcher: ^1.0.0
-  web_socket_channel: ^2.0.0
+  web_socket_channel: ">=2.0.0 <4.0.0"

 dev_dependencies:
   analyzer: '>=3.4.0 <7.0.0'
--- a/build_runner/pubspec.yaml
+++ b/build_runner/pubspec.yaml
@@ -39,12 +39,12 @@ dependencies:
   pub_semver: ^2.0.0
   pubspec_parse: ^1.0.0
   shelf: ^1.0.0
-  shelf_web_socket: ^1.0.0
+  shelf_web_socket: ">=1.0.0 <3.0.0"
   stack_trace: ^1.10.0
   stream_transform: ^2.0.0
   timing: ^1.0.0
   watcher: ^1.0.0
-  web_socket_channel: ^2.0.0
+  web_socket_channel: ">=2.0.0 <4.0.0"
   yaml: ^3.0.0

 dev_dependencies:
brianquinlan commented 1 month ago

@bc-lee Is this blocking you somehow? Could you file an issue with package:builder and CC me?