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

feat: add webSocketURL option #3309

Merged
merged 19 commits into from
May 26, 2021
Merged

feat: add webSocketURL option #3309

merged 19 commits into from
May 26, 2021

Conversation

anshumanv
Copy link
Member

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

migrated existing

Motivation / Use-Case

Move out client.host/port/path to a new option webSocketURL

Breaking Changes

Yes

Additional Info

lib/options.json Outdated Show resolved Hide resolved
lib/utils/DevServerPlugin.js Outdated Show resolved Hide resolved
lib/utils/DevServerPlugin.js Outdated Show resolved Hide resolved
lib/utils/DevServerPlugin.js Outdated Show resolved Hide resolved
lib/utils/DevServerPlugin.js Outdated Show resolved Hide resolved
@anshumanv
Copy link
Member Author

no need review drafts, let me finish

@anshumanv anshumanv force-pushed the wsUrl branch 2 times, most recently from 675e4b0 to 3507a4d Compare May 21, 2021 06:17
@alexander-akait alexander-akait mentioned this pull request May 22, 2021
6 tasks
@anshumanv anshumanv marked this pull request as ready for review May 22, 2021 14:06
lib/options.json Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented May 23, 2021

Codecov Report

Merging #3309 (b5e2227) into master (ed6d27d) will decrease coverage by 0.06%.
The diff coverage is 98.18%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3309      +/-   ##
==========================================
- Coverage   95.70%   95.63%   -0.07%     
==========================================
  Files          34       33       -1     
  Lines        1280     1283       +3     
  Branches      369      369              
==========================================
+ Hits         1225     1227       +2     
- Misses         51       52       +1     
  Partials        4        4              
Impacted Files Coverage Δ
lib/utils/DevServerPlugin.js 98.11% <97.56%> (-0.74%) ⬇️
client-src/utils/createSocketURL.js 100.00% <100.00%> (ø)
client-src/utils/parseURL.js 100.00% <100.00%> (ø)
lib/Server.js 95.80% <100.00%> (-0.05%) ⬇️
lib/utils/normalizeOptions.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed6d27d...b5e2227. Read the comment docs.

@anshumanv
Copy link
Member Author

@alexander-akait @snitin315 CI should be green now 😎

lib/options.json Outdated Show resolved Hide resolved
lib/options.json Outdated Show resolved Hide resolved
lib/utils/DevServerPlugin.js Outdated Show resolved Hide resolved
@alexander-akait
Copy link
Member

@anshumanv Do you need help? I can finish, it is blocker for the next beta release

@anshumanv
Copy link
Member Author

@alexander-akait should be green now, feel free to make any changes or lmk I can do it, thanks for help 👍

Copy link
Member

@snitin315 snitin315 left a comment

Choose a reason for hiding this comment

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

Need to remove public option.

@alexander-akait
Copy link
Member

alexander-akait commented May 25, 2021

Let's finish 👍 WIP

@alexander-akait
Copy link
Member

Finished... We still have some edge cases and places where we can simplify code, but I will do it in the next PRs

@snitin315
Copy link
Member

Also need to remove --public from cli-flags.

@alexander-akait
Copy link
Member

Oh, yes, forgot about it

@alexander-akait
Copy link
Member

I will remove this option in this PR and let's add all options here #3325

@alexander-akait
Copy link
Member

All our tests are complete horror, we need to rewrite them, I spent half a day to finish them

@alexander-akait
Copy link
Member

@snitin315 @anshumanv Can you review?

Comment on lines +90 to +92
webSocketURL: {
path: '/custom/path/',
},
Copy link
Member

Choose a reason for hiding this comment

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

We should add one case with webSocketURL: 'ws://myhost.com:8080/path', and check it normalizes host, port and path correctly from the string.

Copy link

Choose a reason for hiding this comment

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

Will the webSocketURL string allow me to provide wss:// and actually have the browser request using wss://, or will the normalization turn it back into ws:// if https is false? I'm running a reverse https -> http proxy in front, so the dev server should be https:false, but currently doing so, the websocket logic attempts to use ws:// even though the address bar is an https:// url. Just checking to see if this string webSocketURL option will indeed allow me to now force wss:// to be used for the websocket requests.

Copy link
Member

Choose a reason for hiding this comment

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

@bompus you can use ws and wss, and even http/https (we normalize them to ws/wss for backward compatibility). But you should use webSocketURL only when you proxy dev server, if you set https: true we will use wss by default

Copy link
Member

Choose a reason for hiding this comment

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

@snitin315 we have this test (in test/e2e/web-socket-server-and-url.test.js):

client: {
  webSocketURL: `ws://myhost.test:${port2}/foo/test/bar/`,
},
`

Copy link
Member

Choose a reason for hiding this comment

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

All good then 👍🏻

Copy link
Member

Choose a reason for hiding this comment

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

I assume one would need to use auto://0.0.0.0:0/wspath/ if they wanted a specific path?

Yes, maybe make sense to add auto to path too

Copy link

Choose a reason for hiding this comment

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

Great. This should solve my use case 👍

Copy link
Member

Choose a reason for hiding this comment

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

Put in todo, will solve tomorrow

Copy link

Choose a reason for hiding this comment

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

@alexander-akait did you get a chance to start on this yet, or still pending? Just want to make sure it doesn't get buried.

Copy link
Member

Choose a reason for hiding this comment

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

in my todo on tomorrow, don't worry 👍

Copy link
Member Author

@anshumanv anshumanv left a comment

Choose a reason for hiding this comment

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

looks good 👍

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