Skip to content

Commit f81fe40

Browse files
committed
test: remove RxJS from E2E process utility
Replaces RxJS-based retry logic in `execAndWaitForOutputToMatch` with standard async/await for better readability and reduced dependency footprint.
1 parent 588f3b8 commit f81fe40

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

tests/legacy-cli/e2e/utils/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ ts_project(
1919
"//:node_modules/verdaccio",
2020
"//:node_modules/verdaccio-auth-memory",
2121
"//tests:node_modules/@types/tar-stream",
22-
"//tests:node_modules/rxjs",
2322
"//tests:node_modules/tar-stream",
2423
"//tests:node_modules/tree-kill",
2524
],

tests/legacy-cli/e2e/utils/process.ts

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { spawn, SpawnOptions } from 'node:child_process';
22
import * as child_process from 'node:child_process';
3-
import { concat, defer, EMPTY, from, lastValueFrom, catchError, repeat } from 'rxjs';
43
import { getGlobalVariable, getGlobalVariablesEnv } from './env';
54
import treeKill from 'tree-kill';
65
import { delimiter, join, resolve } from 'node:path';
@@ -310,7 +309,7 @@ export async function execAndCaptureError(
310309
}
311310
}
312311

313-
export function execAndWaitForOutputToMatch(
312+
export async function execAndWaitForOutputToMatch(
314313
cmd: string,
315314
args: string[],
316315
match: RegExp,
@@ -322,15 +321,24 @@ export function execAndWaitForOutputToMatch(
322321
// happened just before the build (e.g. `git clean`).
323322
// This seems to be due to host file system differences, see
324323
// https://nodejs.org/docs/latest/api/fs.html#fs_caveats
325-
return lastValueFrom(
326-
concat(
327-
from(_exec({ waitForMatch: match, env }, cmd, args)),
328-
defer(() => waitForAnyProcessOutputToMatch(match, 2500)).pipe(
329-
repeat(20),
330-
catchError(() => EMPTY),
331-
),
332-
),
333-
);
324+
const maxRetries = 20;
325+
let lastError;
326+
327+
try {
328+
return await _exec({ waitForMatch: match, env }, cmd, args);
329+
} catch (e) {
330+
lastError = e;
331+
}
332+
333+
for (let i = 0; i < maxRetries; i++) {
334+
try {
335+
return await waitForAnyProcessOutputToMatch(match, 2500);
336+
} catch (e) {
337+
lastError = e;
338+
}
339+
}
340+
341+
throw lastError;
334342
} else {
335343
return _exec({ waitForMatch: match, env }, cmd, args);
336344
}

0 commit comments

Comments
 (0)