Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for Flutter Web #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

allenwyma
Copy link

Possible fix for Flutter Web


import 'package:phoenix_wings/src/phoenix_connection.dart';

/// PhoenixHtmlConnection handles the creation and use
/// of the underlying websocket connection on browser platforms.
class PhoenixHtmlConnection extends PhoenixConnection {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you help me understand why this has been renamed?

It's resulting in this error on CI

  error • test/phoenix_socket_html_test.dart:11:46 • Undefined name 'PhoenixHtmlConnection'. Try correcting the name to one that is defined, or defining the
          name. • undefined_identifier

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for help keeping the same name: so if your platform is Web or Non-web you'll have the same class name. otherwise you'll have to somehow import the right file. Then no need to import a specific file pending platform.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, there are parts of the code expecting to consume these classes with the original names that haven't been updated.

Would it be possible to get things working without changing the class names?


import 'package:phoenix_wings/src/phoenix_connection.dart';

/// PhoenixIoConnection handles the creation and use
/// of the underlying websocket connection on browser platforms.
class PhoenixIoConnection extends PhoenixConnection {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with renaming?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as comment above.

Comment on lines 1 to +2
import 'dart:async';
import 'dart:html';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like some autoformat thing reordering imports? Not a big deal, but generally prefer to avoid mixing 'formatting' changes with code changes to make the changes easier to understand

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this stuff is usually automatic from the editor. sorry :)

@allenwyma
Copy link
Author

@mfeckie ping :)

@mfeckie
Copy link
Owner

mfeckie commented Feb 7, 2023

@allenwyma Sorry, I've been on leave.

To move forward, we'll need to get the test passing. Can you look at the CI build https://github.com/mfeckie/phoenix_wings/actions/runs/4053099709/jobs/6975286940 and see if you can get that resolved?

@asok
Copy link

asok commented Sep 4, 2024

@mfeckie it seems that the link you provided is expired.

I've tried to run the tests locally. This is the output from running on master:

/Users/asok/development/flutter/bin/dart run test
Resolving dependencies in `/Users/asok/projects/phoenix_wings`...
Downloading packages... (1.7s)
Got dependencies in `/Users/asok/projects/phoenix_wings`.
Building package executable... (2.1s)
Built test:test.
00:05 +26: test/phoenix_socket_io_test.dart: Heartbeat Sends heartbeat
WebSocket connection to ws://localhost:4002/socket/websocket?vsn=2.0.0 failed!: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = localhost, port = 54981
00:06 +28: test/phoenix_socket_io_test.dart: Heartbeat pushes heartbeat data when connected
WebSocket connection to ws://localhost:4002/socket/websocket?vsn=2.0.0 failed!: HttpException: Connection reset by peer, uri = http://localhost:4002/socket/websocket?vsn=2.0.0
00:06 +28: test/phoenix_socket_io_test.dart: Heartbeat Sends heartbeat
WebSocket connection to ws://localhost:4002/socket/websocket?vsn=2.0.0 failed!: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = localhost, port = 54987
00:07 +30: test/phoenix_socket_io_test.dart: Heartbeat pushes heartbeat data when connected
WebSocket connection to ws://localhost:4002/socket/websocket?vsn=2.0.0 failed!: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = localhost, port = 54991
00:08 +32 -1: loading test/phoenix_push_test.dart [E]
  Failed to load "test/phoenix_push_test.dart":
  test/phoenix_push_test.dart:15:32: Error: No named parameter with the name 'returnNullOnMissingStub'.
        as: #MockPhoenixChannel, returnNullOnMissingStub: true),
                                 ^^^^^^^^^^^^^^^^^^^^^^^
  ../../.pub-cache/hosted/pub.dev/mockito-5.4.4/lib/annotations.dart:131:9: Context: Found this candidate, but the arguments don't match.
    const MockSpec({
          ^^^^^^^^
  test/phoenix_push_test.dart:17:31: Error: No named parameter with the name 'returnNullOnMissingStub'.
        as: #MockPhoenixSocket, returnNullOnMissingStub: true),
                                ^^^^^^^^^^^^^^^^^^^^^^^
  ../../.pub-cache/hosted/pub.dev/mockito-5.4.4/lib/annotations.dart:131:9: Context: Found this candidate, but the arguments don't match.
    const MockSpec({
          ^^^^^^^^

To run this test again: /Users/asok/development/flutter/bin/cache/dart-sdk/bin/dart test test/phoenix_push_test.dart -p vm --plain-name 'loading test/phoenix_push_test.dart'

I do get a very similar output when running the command on the Plangora's branch:

 /Users/asok/development/flutter/bin/dart run test
Resolving dependencies in `/Users/asok/projects/phoenix_wings_fork`...
Downloading packages...
Got dependencies in `/Users/asok/projects/phoenix_wings_fork`.
Building package executable... (2.3s)
Built test:test.
00:05 +26: test/phoenix_socket_io_test.dart: Heartbeat Sends heartbeat
WebSocket connection to ws://localhost:4002/socket/websocket?vsn=2.0.0 failed!: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = localhost, port = 55054
00:06 +28: test/phoenix_socket_io_test.dart: Heartbeat pushes heartbeat data when connected
WebSocket connection to ws://localhost:4002/socket/websocket?vsn=2.0.0 failed!: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = localhost, port = 55060
00:06 +28: test/phoenix_socket_io_test.dart: Heartbeat Sends heartbeat
WebSocket connection to ws://localhost:4002/socket/websocket?vsn=2.0.0 failed!: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = localhost, port = 55062
00:07 +30: test/phoenix_socket_io_test.dart: Heartbeat pushes heartbeat data when connected
WebSocket connection to ws://localhost:4002/socket/websocket?vsn=2.0.0 failed!: SocketException: Connection refused (OS Error: Connection refused, errno = 61), address = localhost, port = 55066
00:08 +32 -1: loading test/phoenix_push_test.dart [E]
  Failed to load "test/phoenix_push_test.dart":
  test/phoenix_push_test.dart:15:32: Error: No named parameter with the name 'returnNullOnMissingStub'.
        as: #MockPhoenixChannel, returnNullOnMissingStub: true),
                                 ^^^^^^^^^^^^^^^^^^^^^^^
  ../../.pub-cache/hosted/pub.dev/mockito-5.4.4/lib/annotations.dart:131:9: Context: Found this candidate, but the arguments don't match.
    const MockSpec({
          ^^^^^^^^
  test/phoenix_push_test.dart:17:31: Error: No named parameter with the name 'returnNullOnMissingStub'.
        as: #MockPhoenixSocket, returnNullOnMissingStub: true),
                                ^^^^^^^^^^^^^^^^^^^^^^^
  ../../.pub-cache/hosted/pub.dev/mockito-5.4.4/lib/annotations.dart:131:9: Context: Found this candidate, but the arguments don't match.
    const MockSpec({
          ^^^^^^^^

To run this test again: /Users/asok/development/flutter/bin/cache/dart-sdk/bin/dart test test/phoenix_push_test.dart -p vm --plain-name 'loading test/phoenix_push_test.dart'
00:08 +41 -1: Some tests failed.

Is it the same test that was failing on the CI?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants