fix(docker): bound telegram npm installs · openclaw/openclaw@130464e
vincentkoc
·
2026-05-27
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -240,18 +240,30 @@ package_label="${OPENCLAW_NPM_TELEGRAM_PACKAGE_LABEL:-$install_source}"
|
240 | 240 | echo "Installing ${package_label} from ${install_source}..." |
241 | 241 | |
242 | 242 | npm_install_timeout="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-600s}" |
243 | | -if [ -z "$npm_install_timeout" ] || [ "$npm_install_timeout" = "0" ]; then |
244 | | - npm install -g "$install_source" --no-fund --no-audit |
245 | | -elif command -v timeout >/dev/null 2>&1; then |
246 | | - if timeout --kill-after=1s 1s true >/dev/null 2>&1; then |
247 | | - timeout --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit |
| 243 | +run_npm_install() { |
| 244 | + if [ -z "$npm_install_timeout" ] || [ "$npm_install_timeout" = "0" ]; then |
| 245 | + npm install -g "$install_source" --no-fund --no-audit |
| 246 | + return |
| 247 | + fi |
| 248 | + |
| 249 | + local timeout_bin="" |
| 250 | + if command -v timeout >/dev/null 2>&1; then |
| 251 | + timeout_bin="timeout" |
| 252 | + elif command -v gtimeout >/dev/null 2>&1; then |
| 253 | + timeout_bin="gtimeout" |
| 254 | + fi |
| 255 | + if [ -z "$timeout_bin" ]; then |
| 256 | + echo "timeout or gtimeout is required for OPENCLAW_E2E_NPM_INSTALL_TIMEOUT=$npm_install_timeout" >&2 |
| 257 | + return 127 |
| 258 | + fi |
| 259 | + |
| 260 | + if "$timeout_bin" --kill-after=1s 1s true >/dev/null 2>&1; then |
| 261 | + "$timeout_bin" --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit |
248 | 262 | else |
249 | | - timeout "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit |
| 263 | + "$timeout_bin" "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit |
250 | 264 | fi |
251 | | -else |
252 | | - echo "timeout command not found; running package install without OPENCLAW_E2E_NPM_INSTALL_TIMEOUT" >&2 |
253 | | - npm install -g "$install_source" --no-fund --no-audit |
254 | | -fi |
| 265 | +} |
| 266 | +run_npm_install |
255 | 267 | |
256 | 268 | command -v openclaw |
257 | 269 | openclaw --version |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -264,18 +264,30 @@ install_source="${OPENCLAW_NPM_TELEGRAM_INSTALL_SOURCE:?missing OPENCLAW_NPM_TEL
|
264 | 264 | package_label="${OPENCLAW_NPM_TELEGRAM_PACKAGE_LABEL:-$install_source}" |
265 | 265 | |
266 | 266 | npm_install_timeout="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-600s}" |
267 | | -if [ -z "$npm_install_timeout" ] || [ "$npm_install_timeout" = "0" ]; then |
268 | | - npm install -g "$install_source" --no-fund --no-audit |
269 | | -elif command -v timeout >/dev/null 2>&1; then |
270 | | - if timeout --kill-after=1s 1s true >/dev/null 2>&1; then |
271 | | - timeout --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit |
| 267 | +run_npm_install() { |
| 268 | + if [ -z "$npm_install_timeout" ] || [ "$npm_install_timeout" = "0" ]; then |
| 269 | + npm install -g "$install_source" --no-fund --no-audit |
| 270 | + return |
| 271 | + fi |
| 272 | + |
| 273 | + local timeout_bin="" |
| 274 | + if command -v timeout >/dev/null 2>&1; then |
| 275 | + timeout_bin="timeout" |
| 276 | + elif command -v gtimeout >/dev/null 2>&1; then |
| 277 | + timeout_bin="gtimeout" |
| 278 | + fi |
| 279 | + if [ -z "$timeout_bin" ]; then |
| 280 | + echo "timeout or gtimeout is required for OPENCLAW_E2E_NPM_INSTALL_TIMEOUT=$npm_install_timeout" >&2 |
| 281 | + return 127 |
| 282 | + fi |
| 283 | + |
| 284 | + if "$timeout_bin" --kill-after=1s 1s true >/dev/null 2>&1; then |
| 285 | + "$timeout_bin" --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit |
272 | 286 | else |
273 | | - timeout "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit |
| 287 | + "$timeout_bin" "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit |
274 | 288 | fi |
275 | | -else |
276 | | - echo "timeout command not found; running package install without OPENCLAW_E2E_NPM_INSTALL_TIMEOUT" >&2 |
277 | | - npm install -g "$install_source" --no-fund --no-audit |
278 | | -fi |
| 289 | +} |
| 290 | +run_npm_install |
279 | 291 | command -v openclaw |
280 | 292 | openclaw --version |
281 | 293 | node -p "require('/npm-global/lib/node_modules/openclaw/package.json').version" |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -44,13 +44,19 @@ describe("package Telegram live Docker E2E", () => {
|
44 | 44 | '-e OPENCLAW_E2E_NPM_INSTALL_TIMEOUT="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-600s}"', |
45 | 45 | ); |
46 | 46 | expect(installRun).toContain( |
47 | | -'timeout --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit', |
| 47 | +'"$timeout_bin" --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit', |
48 | 48 | ); |
49 | | -expect(installRun).toContain("timeout --kill-after=1s 1s true >/dev/null 2>&1"); |
| 49 | +expect(installRun).toContain('elif command -v gtimeout >/dev/null 2>&1; then'); |
| 50 | +expect(installRun).toContain("timeout_bin=\"gtimeout\""); |
50 | 51 | expect(installRun).toContain( |
51 | | -'timeout "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit', |
| 52 | +'echo "timeout or gtimeout is required for OPENCLAW_E2E_NPM_INSTALL_TIMEOUT=$npm_install_timeout" >&2', |
| 53 | +); |
| 54 | +expect(installRun).toContain('"$timeout_bin" --kill-after=1s 1s true >/dev/null 2>&1'); |
| 55 | +expect(installRun).toContain( |
| 56 | +'"$timeout_bin" "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit', |
52 | 57 | ); |
53 | 58 | expect(installRun).toContain('npm install -g "$install_source" --no-fund --no-audit'); |
| 59 | +expect(installRun).not.toContain("running package install without OPENCLAW_E2E_NPM_INSTALL_TIMEOUT"); |
54 | 60 | expect(installRun).toContain('"${package_mount_args[@]}"'); |
55 | 61 | expect(installRun).not.toContain('"${docker_env[@]}"'); |
56 | 62 | expect(installRun).toContain("run_logged docker_e2e_docker_run_cmd run --rm"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -147,12 +147,18 @@ describe("RTT harness", () => {
|
147 | 147 | '-e OPENCLAW_E2E_NPM_INSTALL_TIMEOUT="${OPENCLAW_E2E_NPM_INSTALL_TIMEOUT:-600s}"', |
148 | 148 | ); |
149 | 149 | expect(script).toContain( |
150 | | -'timeout --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit', |
| 150 | +'"$timeout_bin" --kill-after=30s "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit', |
151 | 151 | ); |
152 | | -expect(script).toContain("timeout --kill-after=1s 1s true >/dev/null 2>&1"); |
| 152 | +expect(script).toContain('elif command -v gtimeout >/dev/null 2>&1; then'); |
| 153 | +expect(script).toContain("timeout_bin=\"gtimeout\""); |
153 | 154 | expect(script).toContain( |
154 | | -'timeout "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit', |
| 155 | +'echo "timeout or gtimeout is required for OPENCLAW_E2E_NPM_INSTALL_TIMEOUT=$npm_install_timeout" >&2', |
155 | 156 | ); |
| 157 | +expect(script).toContain('"$timeout_bin" --kill-after=1s 1s true >/dev/null 2>&1'); |
| 158 | +expect(script).toContain( |
| 159 | +'"$timeout_bin" "$npm_install_timeout" npm install -g "$install_source" --no-fund --no-audit', |
| 160 | +); |
| 161 | +expect(script).not.toContain("running package install without OPENCLAW_E2E_NPM_INSTALL_TIMEOUT"); |
156 | 162 | expect(script).toContain("run_logged docker_e2e_docker_run_cmd run --rm"); |
157 | 163 | expect(script).not.toContain("run_logged docker run --rm"); |
158 | 164 | expect(heartbeatStartIndex).toBeGreaterThan(sourceIndex); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。