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 client.reconnect option #3912

Merged
merged 17 commits into from Oct 9, 2021
Merged

Conversation

snitin315
Copy link
Member

@snitin315 snitin315 commented Oct 4, 2021

  • 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?

WIP on tests.

Motivation / Use-Case

New option client.reconnect: boolean | number : allows to enable/disable/count of auto connect when client is disconnected

Breaking Changes

None

Additional Info

No

@snitin315 snitin315 changed the title feat: add client.reconnect option [WIP] feat: add client.reconnect option Oct 4, 2021
lib/Server.js Outdated Show resolved Hide resolved
@@ -1627,6 +1638,10 @@ class Server {
this.sendMessage([client], "progress", this.options.client.progress);
}

if (this.options.client && this.options.client.reconnect) {
this.sendMessage([client], "reconnect", this.options.client.reconnect);
}
Copy link
Member

Choose a reason for hiding this comment

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

We need handler in our client for this like for progress/etc, so developers can change value using web socket API

lib/Server.js Outdated Show resolved Hide resolved
Copy link
Member

@alexander-akait alexander-akait 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, one note above, and let's add tests

@codecov
Copy link

codecov bot commented Oct 5, 2021

Codecov Report

Merging #3912 (2c00428) into master (7298114) will decrease coverage by 0.35%.
The diff coverage is 76.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3912      +/-   ##
==========================================
- Coverage   92.94%   92.58%   -0.36%     
==========================================
  Files          14       14              
  Lines        1346     1362      +16     
  Branches      467      474       +7     
==========================================
+ Hits         1251     1261      +10     
- Misses         88       93       +5     
- Partials        7        8       +1     
Impacted Files Coverage Δ
bin/cli-flags.js 100.00% <ø> (ø)
client-src/index.js 78.18% <42.85%> (-2.59%) ⬇️
lib/Server.js 93.86% <100.00%> (+0.05%) ⬆️
lib/servers/WebsocketServer.js 91.42% <0.00%> (-5.72%) ⬇️

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 7298114...2c00428. Read the comment docs.

@alexander-akait
Copy link
Member

Looks good, let's fix the tests

@snitin315 snitin315 changed the title [WIP] feat: add client.reconnect option feat: add client.reconnect option Oct 8, 2021
@snitin315 snitin315 marked this pull request as ready for review October 8, 2021 09:57
@alexander-akait alexander-akait merged commit 5edad76 into master Oct 9, 2021
@alexander-akait alexander-akait deleted the feat/client-reconnect-option branch October 9, 2021 13:55
@alexander-akait
Copy link
Member

Thanks

@alexander-akait
Copy link
Member

@snitin315 I have another good task for you, we should implement the server option, like we have webSocketServer, it can be:

{
  server: "http" | "https" | "spdy" | { type: "http" | "https" | "spdy", options }
}

options will be passed to https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L1565, https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L1577, https://github.com/webpack/webpack-dev-server/blob/master/lib/Server.js#L1582

So it allows developer setup many options for server, regarding to http2 and https options, they will be removed in future in favor

webpack --server-type http
webpack --server-type https --server-options-key ./path/to/key
webpack --server-type http2 --server-options-key ./path/to/key

But now we will keep them to avoid breaking change, but the server options are more important, i.e.

// Pseudo code
const serverOptions = { 
  ...this.options.https,
  ...this.options.server.options
};

Ideally we should do this normalization in normalizeOptions and inside dev server we should use only this.options.server.type and this.options.server.options

@snitin315
Copy link
Member Author

@alexander-akait sounds good, I will implement 👍

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.

None yet

2 participants