From 9de36ed48cbdeaf57fdea4b32458dceae69f56ca Mon Sep 17 00:00:00 2001 From: Marco Collovati Date: Tue, 11 Jun 2024 10:21:28 +0300 Subject: [PATCH] fix: wait for output reading to complete before parsing version NodeInstall.getVersion currently does not block waiting for STDOUT and STDERR to be read completely. This causes random failure during node installation because of forcing an empty version. This change waits for future to complete before parsing the version value. --- .../flow/server/frontend/installer/NodeInstaller.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/flow-server/src/main/java/com/vaadin/flow/server/frontend/installer/NodeInstaller.java b/flow-server/src/main/java/com/vaadin/flow/server/frontend/installer/NodeInstaller.java index 84e169eeff9..d2620fef0ac 100644 --- a/flow-server/src/main/java/com/vaadin/flow/server/frontend/installer/NodeInstaller.java +++ b/flow-server/src/main/java/com/vaadin/flow/server/frontend/installer/NodeInstaller.java @@ -26,6 +26,7 @@ import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import org.apache.commons.io.FileUtils; import org.slf4j.Logger; @@ -559,8 +560,14 @@ private static FrontendVersion getVersion(String tool, throw new IOException("Process exited with non 0 exit code. (" + exitCode + ")"); } - return FrontendUtils.parseFrontendVersion( - streamConsumer.getNow(new Pair<>("", "")).getFirst()); + String version; + try { + version = streamConsumer.get().getFirst(); + } catch (ExecutionException e) { + getLogger().debug("Cannot read {} version", tool, e); + version = ""; + } + return FrontendUtils.parseFrontendVersion(version); } catch (InterruptedException | IOException e) { throw new InstallationException(String.format( "Unable to detect version of %s. %s", tool,