Skip to content

Commit

Permalink
hone down fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-roemer committed Apr 17, 2019
1 parent 2729102 commit 3609ce6
Showing 1 changed file with 5 additions and 30 deletions.
35 changes: 5 additions & 30 deletions plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,40 +171,15 @@ class DashboardPlugin {
options.stats || { colors: true };

// We only need errors/warnings for stats information for finishing up.
// This allows us to avoid sending a full stats object to the CLI which
// can cause socket.io client disconnects for large objects.
// See: https://github.com/FormidableLabs/webpack-dashboard/issues/279
const statsJsonOptions = {
all: false,
errors: true,
warnings: true,
warnings: true
};

// TODO(socketio-bug): Remove all temp code here.
// https://github.com/FormidableLabs/webpack-dashboard/issues/279
const statsObj = stats.toJson(statsJsonOptions);
try {
if (process.env.TMP_BIG_STATS === "true") {
console.log("TODO REMOVE STATS KEYS", Object.keys(statsObj));
const firstSourceMod = (statsObj.modules || []).filter(mod => !!mod.source)[0];
if (firstSourceMod) {
// Get starting size of stats object and our extra stuff to augment.
const startingSize = JSON.stringify(statsObj).length + 7;

// Find the first source module and patch it with a _huge_ string.
// This value will likely fail on most machines.
const largeStringSize = 115915534; // From issue 279. Definitely hits it.

// Experimentally observed on one machine.
const experimentalSizeSucceeds = 99998786;
const experimentalSizeFails = 99998787;

// Choose a size.
const pad = largeStringSize;
firstSourceMod.source += `\n// ${"".padEnd(pad - startingSize, "*")}\n`;
}
}
} catch (err) {
console.error(err);
}

handler([
{
type: "status",
Expand All @@ -223,7 +198,7 @@ class DashboardPlugin {
value: {
errors: stats.hasErrors(),
warnings: stats.hasWarnings(),
data: statsObj // TODO: UNWIND
data: stats.toJson(statsJsonOptions)
}
},
{
Expand Down

0 comments on commit 3609ce6

Please sign in to comment.