diff --git a/scripts/e2e/npm-telegram-live-docker.sh b/scripts/e2e/npm-telegram-live-docker.sh index e8ce37b364c..c4732938c3e 100755 --- a/scripts/e2e/npm-telegram-live-docker.sh +++ b/scripts/e2e/npm-telegram-live-docker.sh @@ -223,6 +223,7 @@ run_logged() { echo "Running package Telegram live Docker E2E ($PACKAGE_LABEL)..." run_logged docker_e2e_docker_run_cmd run --rm \ -e COREPACK_ENABLE_DOWNLOAD_PROMPT=0 \ + -e OPENCLAW_E2E_NPM_INSTALL_TIMEOUT="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-600s}" \ -e OPENCLAW_NPM_TELEGRAM_INSTALL_SOURCE="$package_install_source" \ -e OPENCLAW_NPM_TELEGRAM_PACKAGE_LABEL="$PACKAGE_LABEL" \ ${package_mount_args[@]+"${package_mount_args[@]}"} \ @@ -237,7 +238,16 @@ export PATH="$NPM_CONFIG_PREFIX/bin:$PATH" install_source="${OPENCLAW_NPM_TELEGRAM_INSTALL_SOURCE:?missing OPENCLAW_NPM_TELEGRAM_INSTALL_SOURCE}" package_label="${OPENCLAW_NPM_TELEGRAM_PACKAGE_LABEL:-$install_source}" echo "Installing ${package_label} from ${install_source}..." -npm install -g "$install_source" --no-fund --no-audit + +npm_install_timeout="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-600s}" +if [ -z "$npm_install_timeout" ] || [ "$npm_install_timeout" = "0" ]; then + npm install -g "$install_source" --no-fund --no-audit +elif command -v timeout >/dev/null 2>&1; then + timeout --foreground --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit +else + echo "timeout command not found; running package install without OPENCLAW_E2E_NPM_INSTALL_TIMEOUT" >&2 + npm install -g "$install_source" --no-fund --no-audit +fi command -v openclaw openclaw --version diff --git a/scripts/e2e/npm-telegram-rtt-docker.sh b/scripts/e2e/npm-telegram-rtt-docker.sh index 67aaf7c6179..c5758a5ae6b 100755 --- a/scripts/e2e/npm-telegram-rtt-docker.sh +++ b/scripts/e2e/npm-telegram-rtt-docker.sh @@ -207,6 +207,7 @@ docker_env=( -e OPENCLAW_NPM_TELEGRAM_WARM_SAMPLES="${OPENCLAW_NPM_TELEGRAM_WARM_SAMPLES:-20}" -e OPENCLAW_NPM_TELEGRAM_SAMPLE_TIMEOUT_MS="${OPENCLAW_NPM_TELEGRAM_SAMPLE_TIMEOUT_MS:-30000}" -e OPENCLAW_NPM_TELEGRAM_MAX_FAILURES="${OPENCLAW_NPM_TELEGRAM_MAX_FAILURES:-${OPENCLAW_NPM_TELEGRAM_WARM_SAMPLES:-20}}" + -e OPENCLAW_E2E_NPM_INSTALL_TIMEOUT="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-600s}" ) forward_env_if_set() { @@ -262,7 +263,15 @@ export PATH="$NPM_CONFIG_PREFIX/bin:$PATH" install_source="${OPENCLAW_NPM_TELEGRAM_INSTALL_SOURCE:?missing OPENCLAW_NPM_TELEGRAM_INSTALL_SOURCE}" package_label="${OPENCLAW_NPM_TELEGRAM_PACKAGE_LABEL:-$install_source}" -npm install -g "$install_source" --no-fund --no-audit +npm_install_timeout="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-600s}" +if [ -z "$npm_install_timeout" ] || [ "$npm_install_timeout" = "0" ]; then + npm install -g "$install_source" --no-fund --no-audit +elif command -v timeout >/dev/null 2>&1; then + timeout --foreground --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit +else + echo "timeout command not found; running package install without OPENCLAW_E2E_NPM_INSTALL_TIMEOUT" >&2 + npm install -g "$install_source" --no-fund --no-audit +fi command -v openclaw openclaw --version node -p "require('/npm-global/lib/node_modules/openclaw/package.json').version" diff --git a/test/scripts/npm-telegram-live.test.ts b/test/scripts/npm-telegram-live.test.ts index 357c17b7918..101d20dec1a 100644 --- a/test/scripts/npm-telegram-live.test.ts +++ b/test/scripts/npm-telegram-live.test.ts @@ -40,6 +40,12 @@ describe("package Telegram live Docker E2E", () => { expect(installRunStart).toBeGreaterThanOrEqual(0); expect(installRunEnd).toBeGreaterThan(installRunStart); + expect(installRun).toContain( + '-e OPENCLAW_E2E_NPM_INSTALL_TIMEOUT="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-600s}"', + ); + expect(installRun).toContain( + 'timeout --foreground --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit', + ); expect(installRun).toContain('npm install -g "$install_source" --no-fund --no-audit'); expect(installRun).toContain('"${package_mount_args[@]}"'); expect(installRun).not.toContain('"${docker_env[@]}"'); diff --git a/test/scripts/rtt-harness.test.ts b/test/scripts/rtt-harness.test.ts index 16118bd6bb0..f3eaa132a6a 100644 --- a/test/scripts/rtt-harness.test.ts +++ b/test/scripts/rtt-harness.test.ts @@ -143,6 +143,12 @@ describe("RTT harness", () => { expect(installEnvSnapshotIndex).toBeGreaterThanOrEqual(0); expect(convexSecretForwardIndex).toBeGreaterThan(installEnvSnapshotIndex); expect(packageInstallIndex).toBeLessThan(credentialAcquireIndex); + expect(script).toContain( + '-e OPENCLAW_E2E_NPM_INSTALL_TIMEOUT="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-600s}"', + ); + expect(script).toContain( + 'timeout --foreground --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit', + ); expect(script).toContain("run_logged docker_e2e_docker_run_cmd run --rm"); expect(script).not.toContain("run_logged docker run --rm"); expect(heartbeatStartIndex).toBeGreaterThan(sourceIndex);