-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: disable socket injection when hot & liveReload are disabled #2133
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2133 +/- ##
==========================================
+ Coverage 92.56% 92.58% +0.01%
==========================================
Files 33 33
Lines 1265 1268 +3
Branches 361 363 +2
==========================================
+ Hits 1171 1174 +3
Misses 87 87
Partials 7 7
Continue to review full report at Codecov.
|
@@ -24,7 +24,8 @@ Array [ | |||
|
|||
exports[`Client iframe console.log liveReload disabled 1`] = ` | |||
Array [ | |||
"Hey.", | |||
"Failed to load resource: the server responded with a status of 404 (Not Found)", | |||
"Failed to load resource: the server responded with a status of 404 (Not Found)", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks something wrong expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes liveReload is disabled and hot is disabled too that's why the WebSocket is not working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is possible that this could be a variable number of 404 error messages, since the client keeps retrying to connect. Maybe this should be handled some way for this particular test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Loonride any idea to handle these 404 errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Loonride any idea to handle these 404 errors?
@EslamHiko Sorry I missed your reply, it seems tests generally pass as the timing is consistent to only output the error message twice, but just in case:
You could check that every element in that array is the same. Then make the snapshot only test the first element of the output array. This will allow for a variable number of the same error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! One note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -60,3 +66,99 @@ describe('WebsocketClient', () => { | |||
}); | |||
}); | |||
}); | |||
|
|||
describe('websocket client injection', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to the test/server
directory. Either in Server.test.js
, or possibly a new test file of its own. @evilebottnawi thoughts on where it should go exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@EslamHiko yep, let's move this test to test/server
@Loonride maybe test/server/hot-and-liveReload-integration
, no idea how better naming this 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Loonride @evilebottnawi okay, will move it to test/server/socket-injection
what do you think about the name? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/server/socket-injection.test.js
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One note and we can merge this 👍
test/server/socket-injection.test.js
Outdated
done(); | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add test where hot: false, liveReload: true
for explicit check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
f8674e0
@@ -25,6 +25,9 @@ Array [ | |||
exports[`Client console.log liveReload disabled 1`] = ` | |||
Array [ | |||
"Hey.", | |||
"Failed to load resource: the server responded with a status of 404 (Not Found)", | |||
"[WDS] Disconnected!", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should I add a check to disable "[WDS] Disconnected!"
message when hot
& liveReload
are disabled ? @Loonride @evilebottnawi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes, better output message like [WDS] hot and live reload was disables
client-src/default/index.js
Outdated
log.error('[WDS] Disconnected!'); | ||
if (options.hot || options.liveReload) log.error('[WDS] Disconnected!'); | ||
else | ||
{log.error('[WDS] Hot Module Replacement & Live Reloading are disabled!');} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (condition) {
// Logic
} else {
// Logic
}
Codecov Report
@@ Coverage Diff @@
## v4 #2133 +/- ##
==========================================
+ Coverage 93.77% 93.93% +0.16%
==========================================
Files 34 34
Lines 1333 1287 -46
Branches 381 368 -13
==========================================
- Hits 1250 1209 -41
+ Misses 81 77 -4
+ Partials 2 1 -1
Continue to review full report at Codecov.
|
@@ -737,7 +737,9 @@ class Server { | |||
this.hostname = hostname; | |||
|
|||
return this.listeningApp.listen(port, hostname, (err) => { | |||
this.createSocketServer(); | |||
if (this.options.hot || this.options.liveReload !== false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- if (this.options.hot || this.options.liveReload !== false) {
+ if (this.options.hot || this.options.liveReload) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hiroppy sorry for my late reply but I think if I changed it, it won't create the socket server if options.liveReload was undefined
the default value. I suggest making little refactor and write this.options.liveReload = this.options.liveReload !== false
at the beginning of the constructor and replace all this.options.liveReload !== false
with this.options.liveReload
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @hiroppy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, we will fix this in the next version.
@evilebottnawi Is it possible this should be on |
@Loonride hm, what is use case for this action? |
I can't think of a good use case. I was thinking hypothetically someone could connect to the socket server without using the served client, but there is likely no use for this. Anyway, LGTM. |
/cc @hiroppy @evilebottnawi @Loonride CI is green 😄 |
/cc @EslamHiko we merge this for next release because #2133 (comment), anyway thanks for PR, we will try to release next version on next/next-next week (we are working on webpack-dev-middleware) |
* chore(deps): upgrade chokidar * chore(deps): switch to promise method without async for close * chore(ci): remove node v6 * chore(deps): fix issue of closing watchers before middleware * chore(deps): upgrade chokidar to v3.4.0
* chore(deps): upgrade deps * style: run prettier * test: update * ci: remove Node@8 * test(cli): add windows support * chore(deps): downgrade puppeteer * chore(deps): downgrade some deps * fix(hot): enable hot option as default (webpack#2546) BREAKING CHANGE: the `hot` option is `true` by default, the `hotOnly` option was removed in favor `{ hot: 'only' }` * fix: remove lazy and filename options (webpack#2544) BREAKING CHANGE: `lazy` and `filename` options was removed
BREAKING CHANGE: switch default transportMode to ws
…nd requestCert to https object (webpack#2564)
BREAKING CHANGE: the `client` now in `default` directory
BREAKING CHANGE: the `setup` was removed, `before` and `after` options were renamed to `onBeforeSetupMiddleware` and `onAfterSetupMiddleware`
/cc @EslamHiko Can you send a PR for v4? |
80abcb2
to
0787620
Compare
@evilebottnawi I failed to rebase & created a fresh PR here: #2601 |
For Bugs and Features; did you add new tests?
Yes
Motivation / Use-Case
Solves : #1831
Breaking Changes
No
Additional Info