fix(scripts): clamp plugin lifecycle timers · openclaw/openclaw@8ef73be
vincentkoc
·
2026-06-22
·
via Recent Commits to openclaw:main
File tree
scripts/e2e/lib/plugin-lifecycle-matrix
| Original file line number | Diff line number | Diff line change |
|---|
@@ -48,11 +48,20 @@ function readPositiveNumberEnv(name, fallback) {
|
48 | 48 | return value; |
49 | 49 | } |
50 | 50 | |
51 | | -const pollMs = readPositiveIntEnv("OPENCLAW_PLUGIN_LIFECYCLE_METRIC_POLL_MS", 100); |
52 | | -const timeoutMs = readPositiveIntEnv("OPENCLAW_PLUGIN_LIFECYCLE_PHASE_TIMEOUT_MS", 300000); |
53 | | -const timeoutKillGraceMs = readPositiveIntEnv( |
54 | | -"OPENCLAW_PLUGIN_LIFECYCLE_TIMEOUT_KILL_GRACE_MS", |
55 | | -2000, |
| 51 | +const MAX_TIMER_TIMEOUT_MS = 2_147_000_000; |
| 52 | + |
| 53 | +function clampTimerTimeoutMs(valueMs) { |
| 54 | +return Math.min(Math.max(Math.floor(valueMs), 1), MAX_TIMER_TIMEOUT_MS); |
| 55 | +} |
| 56 | + |
| 57 | +const pollMs = clampTimerTimeoutMs( |
| 58 | +readPositiveIntEnv("OPENCLAW_PLUGIN_LIFECYCLE_METRIC_POLL_MS", 100), |
| 59 | +); |
| 60 | +const timeoutMs = clampTimerTimeoutMs( |
| 61 | +readPositiveIntEnv("OPENCLAW_PLUGIN_LIFECYCLE_PHASE_TIMEOUT_MS", 300000), |
| 62 | +); |
| 63 | +const timeoutKillGraceMs = clampTimerTimeoutMs( |
| 64 | +readPositiveIntEnv("OPENCLAW_PLUGIN_LIFECYCLE_TIMEOUT_KILL_GRACE_MS", 2000), |
56 | 65 | ); |
57 | 66 | const maxRssKbThreshold = readPositiveIntEnv( |
58 | 67 | "OPENCLAW_PLUGIN_LIFECYCLE_MAX_RSS_KB", |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -253,6 +253,41 @@ describe("plugin lifecycle resource sampler", () => {
|
253 | 253 | }, |
254 | 254 | ); |
255 | 255 | |
| 256 | +it.runIf(process.platform === "linux")("clamps oversized timer env values", () => { |
| 257 | +const dir = makeTempDir(); |
| 258 | +const summary = path.join(dir, "summary.tsv"); |
| 259 | +const oversizedTimerMs = "2147000001"; |
| 260 | +const result = spawnSync( |
| 261 | +"node", |
| 262 | +[ |
| 263 | +scriptPath, |
| 264 | +summary, |
| 265 | +"oversized-timers", |
| 266 | +"--", |
| 267 | +"node", |
| 268 | +"-e", |
| 269 | +"setTimeout(() => process.exit(0), 25)", |
| 270 | +], |
| 271 | +{ |
| 272 | +cwd: process.cwd(), |
| 273 | +encoding: "utf8", |
| 274 | +env: { |
| 275 | + ...process.env, |
| 276 | +OPENCLAW_PLUGIN_LIFECYCLE_METRIC_POLL_MS: oversizedTimerMs, |
| 277 | +OPENCLAW_PLUGIN_LIFECYCLE_PHASE_TIMEOUT_MS: oversizedTimerMs, |
| 278 | +OPENCLAW_PLUGIN_LIFECYCLE_TIMEOUT_KILL_GRACE_MS: oversizedTimerMs, |
| 279 | +}, |
| 280 | +timeout: 5000, |
| 281 | +}, |
| 282 | +); |
| 283 | + |
| 284 | +expect(result.status).toBe(0); |
| 285 | +expect(result.stderr).not.toContain("TimeoutOverflowWarning"); |
| 286 | +expect(readFileSync(summary, "utf8")).toMatch( |
| 287 | +/^oversized-timers\t\d+\t[\d.]+\t\d+\t[\d.]+\t$/mu, |
| 288 | +); |
| 289 | +}); |
| 290 | + |
256 | 291 | it.runIf(process.platform === "linux")( |
257 | 292 | "kills stubborn descendants after the timeout grace period", |
258 | 293 | () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。