-
Notifications
You must be signed in to change notification settings - Fork 363
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
BUG: Large webpack stats bundles cause socket.io client disconnect. #279
Comments
Thanks for the issue @westbrook-asapp. I think your intuition about it being Babel-related is probably correct. Do you see the same behavior if you downgrade to Babel 6? Seeing no output like that would lead me to believe that those items (modules, assets, problems) are, for whatever reason, not being sent by |
@westbrook-asapp so I attempted to reproduce the issue by using
One last thing I noticed – you seem to pass a Again, having a reproducible example you can share is the best way for us to help you. We can't get very far without it unfortunately 😢 |
@parkerziegler Thanks for your entry analysis of what may be going on here. Let me take this and see if I can't get closer to the issue today and tomorrow. If not, I'll do the work to sanitize a repro. I attempted this for a previous issue and found out from my team post haste that I hadn't done as good a job as I had hoped, so it may take a little time. I had created a stats out put for that work, so with that and your notes above I should be able to bring something productive back to this issue soon! |
Thanks a bunch @westbrook-asapp, great to have your help! |
Super weird, it looks like it never even runs this code |
This would probably be the next place to look https://github.com/FormidableLabs/webpack-dashboard/blob/master/dashboard/index.js#L47-L66 to see if those methods are ever getting called. |
So, I just ran it with
And |
Once the |
I also tested with |
Roping in @ryan-roemer on this one. |
@westbrook-asapp -- If you remove |
That's one of the things that's weird, as shown in the image above it always goes to |
Gotcha. The ... and then maybe after you've reached that state turn back to Good luck and thanks for all your work! |
I'll keep looking at it. Confused because all of the other plugins work, live rebuild works, HappyPack works, ForkTsCheckerWebpackPlugin works, ExtractTextPlugin works, they just never seem to finish. 😖 I'll keep at it. Thanks for helping me thing it through. |
Can you try with Just talking out here -- plugins can hook in to different lifecycle events and that may explain some differences. On our end:
|
Thanks @ryan-roemer this was actually super helpful. I dug into the events that Gonna look into whether
Hopefully, in my search I can find a specific cause as this is just a workaround, but this feels like I'm getting closer. |
I was getting the above in Separately, I did finally get the
as opposed to:
I've not enough context to judge whether that means this is more likely a The output of the stats is here if reviewing it might help my cause. |
Confirmation question, should the If not, how do the changes in https://github.com/FormidableLabs/webpack-dashboard/blob/master/plugin/index.js make it to https://github.com/FormidableLabs/webpack-dashboard/blob/master/dashboard/index.js? I see a number of calls to states like Thanks in advance for your ongoing support on finding a resolution to this! |
Correct, as I understand it, the webpack plugin binds webpack events to socket.io // webpack plugin `failed` hook causes socket.io to emit `status`, `operations` messages
webpackHook(compiler, "failed", () => {
handler([
{
type: "status",
value: "Failed"
},
{
type: "operations",
value: `idle${getTimeMessage(timer)}`
}
]);
}); Then over in the CLI land, the socket.io listened stuff is punched to: https://github.com/FormidableLabs/webpack-dashboard/blob/master/dashboard/index.js#L104 this.actionForMessageType[data.type](data); which then uses // ... edited ...
this.actionForMessageType = {
// ...
operations: this.setOperations.bind(this),
status: this.setStatus.bind(this),
// ...
}; Does that help? For debugging purposes, you should be able to add Thanks again for your continued hacking at this! |
Ok, so I'm at least a little on the right page. However, what I'm seeing is, for instance this line of code will run https://github.com/FormidableLabs/webpack-dashboard/blob/master/plugin/index.js#L165 (which should demarcate the "Success" display), and I can Any thoughts on why something might not be making it onto the socket? |
And, to be clear, it seems to only be the things that happen in |
@westbrook-asapp -- So, just to summarize that I understand what you're saying. This stuff does get all the way to the CLI calling webpackHook(compiler, "compile", () => {
webpackHook(compiler, "invalid", () => {
webpackHook(compiler, "failed", () => { However, this plugin hook is fired and does call webpackHook(compiler, "done", stats => { ... and in your experimentation, only the Did I correctly summarize all the above? In any case, is there any chance you can give us a minimal reproduction of that? (Ideally a repository or codesandbox with install and command line instructions to reproduce the error...) And I can add in any |
That is what I am seeing right now, yes. I'll see if I can boil it down to happen somewhere else. 🤞 |
Do you think there is any limit on through put on that socket? In my repro I couldn't recreate, so I focused on specific |
Let's see if the sheer size of the stats object is causing problems. Can you try something like the following that doesn't send the entire stats object works? Here's an untested diff that may help get you started: diff --git a/plugin/index.js b/plugin/index.js
index f90d64e..36ff05a 100644
--- a/plugin/index.js
+++ b/plugin/index.js
@@ -164,6 +164,17 @@ class DashboardPlugin {
|| options.stats
|| { colors: true };
+
+ console.log("TODO HERE DONE", JSON.stringify({
+ stats: {
+ // Just get string length instead of actual object.
+ length: JSON.stringify(stats.toJson()).length,
+ errors: stats.hasErrors(),
+ warnings: stats.hasWarnings(),
+ string: stats.toString(statsOptions).length,
+ }
+ }, null, 2));
+
handler([
{
type: "status",
@@ -182,12 +193,12 @@ class DashboardPlugin {
value: {
errors: stats.hasErrors(),
warnings: stats.hasWarnings(),
- data: stats.toJson()
+ data: {}
}
},
{
type: "log",
- value: stats.toString(statsOptions)
+ value: "TODO REMOVED STATS TO STRING"
}
]);
|
This seems to be it. With a little extra massaging to the above it does it thing all the way to "Status: Success" as well as all modules/assets in the output (while hard to copy, is it possible to get cursor insertion in the output? I can make a separate ticket) looks like this:
😱 🤦♂️ Always the absolute last thing in the "maybe it's..." pile! On one hand, this is exactly why the longer arch of the project I am working on was started (the app was too big and hard to maintain/own), so there's a path towards my team addressing this on our side, but on the other hand, do you think there's a workaround/setting on your part that I could leverage or you could add to support in the sort term? |
I've confirmed the bug with a simple reproduction placed at: #281 (basically I just pad a single modules I've further debugged that it's causing a socket.io disconnection. I'm going to take a break from the issue for a bit, but we all can perhaps look for solutions either in socket.io client, socket.io server, or potentially something super heavyweight like switching to a different means of IPC than socket.io... |
Alternate question: What exactly does having the stats object buy a user? The majority of displayed data seems to come from the information sent as Spitballing here, but super happy to have something to verify this thing for you and the team. Thanks for helping me get this far! |
That A hacky solution could be to do something like mutate ... but if possible, I'd rather solve our IPC problem which I think has a lot of potential avenues... |
Makes sense. I only asked because I can't see anything missing right off with this change (short term fork likely on our end 🙈):
Sizes, duplications, modules, assets, etc. all seem to display, but I'm still pretty new to the tool, so thanks for correcting me. Let me know if there is anything else I can do to support a longer term solution here! |
You know, a "medium-level" thing we could do is to pull I'm not sure if I immediately have time, but I think I could work up something along those lines without too much craziness... |
WOAH, WAIT A MINUTE. We already do |
Wow @westbrook-asapp that was a super simple fix! Can you pull down and see if #281 works for y'all now? Thanks! |
Ha, wish it has been so simple to find! I'll test it out today. |
@westbrook-asapp if it does fix your issue I'll publish a patch for it ASAP so your team can get the latest. Thanks @ryan-roemer and @westbrook-asapp for all of your hard work on this – work like this really makes me ❤️ the OSS community. |
Working!! 💣 💥 🔥 🚒 Thanks so much to you both for turning this around so quickly. One note: this code runs, even though it doesn't impede future work:
It may be nice to make the copy a little more informative (it is also a bit scary if I didn't know why it was happening), but don't let this sort of nit hold things up. |
@westbrook-asapp -- Great! Good observation about the message. @parkerziegler -- I'm going to do a little extra work to only log that out if we disconnect _ before_ reaching success state at least once. |
@westbrook-asapp -- Can you pull the PR one more time, try out c819882 and see if that is a better DX? |
@ryan-roemer cool I'll leave it to you to merge and just ping me so I can cut a release. |
Much nicer! Let's 💯 |
@parkerziegler Looking forward to a new version this morning. Thanks for everyone's help on this! |
@westbrook-asapp latest |
After upgrading to webpack@4 and webpack-dashboard@3.0.2 I'm able to get a full
Success
notification as well as Modules/Assets/Problems display. However, when also updating babel to @7, jest to @24, and storybook to @5 (I think only really babel is related, but for completeness) I'm able to build and watch my application seemingly with no issues in the code output, but I'm unable to get theStatus
to go toSuccess
or the Modules/Assets/Problems sections to display.If there is something easy that I might be missing, I'd love to hear it, but mostly I'm looking for places in particular to look for issues with my set up here.
====================================================================
If the issue is visual, please provide screenshots here
====================================================================
Steps to reproduce the problem
====================================================================
Please provide a gist of relevant files
ENABLE_SOURCE_MAPS=true NODE_ENV=development webpack-dashboard -- webpack-dev-server --config webpack.config.local-dev.js --host 0.0.0.0 --no-inline
====================================================================
More Details
echo $TERM
? xterm-256colorThe text was updated successfully, but these errors were encountered: