Skip to content

Commit f04bba7

Browse files
authored
fix: Log webpack output on failure (#10628)
Log as error any output from webpack when webpack exits prematurely without success/failure. Closes #7472
1 parent b067d2c commit f04bba7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

flow-server/src/main/java/com/vaadin/flow/server/DevModeHandler.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ public final class DevModeHandler implements RequestHandler {
109109

110110
private boolean notified = false;
111111

112+
private StringBuilder cumulativeOutput = new StringBuilder();
113+
112114
private volatile String failedOutput;
113115

114116
private AtomicBoolean isDevServerFailedToStart = new AtomicBoolean();
@@ -469,6 +471,9 @@ private void readLinesLoop(Pattern success, Pattern failure,
469471
output.append(cleanLine).append(System.lineSeparator());
470472
}
471473

474+
// save output so as it can be used to log exception if run fails
475+
cumulativeOutput.append(cleanLine).append(System.lineSeparator());
476+
472477
boolean succeed = success.matcher(line).find();
473478
boolean failed = failure.matcher(line).find();
474479
// We found the success or failure pattern in stream
@@ -478,6 +483,7 @@ private void readLinesLoop(Pattern success, Pattern failure,
478483
failedOutput = failed ? output.toString() : null;
479484
// reset output and logger for the next compilation
480485
output = getOutputBuilder();
486+
cumulativeOutput = new StringBuilder();
481487
log = info;
482488
// Notify DevModeHandler to continue
483489
doNotify();
@@ -654,6 +660,9 @@ private boolean doStartWebpack(DeploymentConfiguration config,
654660
}
655661

656662
if (!webpackProcess.get().isAlive()) {
663+
getLogger().error(
664+
String.format("Webpack failed with the exception:%n%s",
665+
cumulativeOutput.toString()));
657666
throw new IllegalStateException("Webpack exited prematurely");
658667
}
659668

0 commit comments

Comments
 (0)