Skip to content

Commit 5642ecc

Browse files
Retry npm commands on TS sanity plugin (#1026)
Signed-off-by: Oriol Muñoz <oriol.munoz@digitalasset.com>
1 parent f53f369 commit 5642ecc

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/plugins/TokenStandardCliSanityCheckPlugin.scala

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ class TokenStandardCliSanityCheckPlugin(
131131
token: String,
132132
participantPort: Int,
133133
extraArgs: Seq[String],
134+
retries: Int = 3,
134135
)(implicit
135136
tc: TraceContext
136137
): String = {
@@ -159,8 +160,16 @@ class TokenStandardCliSanityCheckPlugin(
159160
if (exitCodeTry.toOption.exists(_ != 0) || exitCodeTry.isFailure) {
160161
logger.error(s"Failed to run $args: $exitCodeTry. Dumping output.")(TraceContext.empty)
161162
readLines.foreach(logger.error(_)(TraceContext.empty))
162-
// sometimes readlines is empty...?
163-
throw new RuntimeException(s"$args failed: ${readLines}")
163+
if (retries > 0) {
164+
// node commands sometimes give no logs whatsoever, and sometimes they segfault and dump a native stack trace,
165+
// so retrying seems like the best solution.
166+
// If the cause of the error is not-node-related, it should fail quick enough that it won't slow down tests too much.
167+
logger.info(s"Retrying command $args")
168+
runCommand(command, partyId, token, participantPort, extraArgs, retries - 1)
169+
} else {
170+
// sometimes readlines is empty...?
171+
throw new RuntimeException(s"$args failed: ${readLines}")
172+
}
164173
}
165174
val result = readLines
166175
.dropWhile(line => !line.startsWith("[") && !line.startsWith("{")) // remove npm noise

0 commit comments

Comments
 (0)