fix: parse session lock env timeouts strictly · openclaw/openclaw@5880782
steipete
·
2026-05-29
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -477,6 +477,47 @@ describe("acquireSessionWriteLock", () => {
|
477 | 477 | }); |
478 | 478 | }); |
479 | 479 | |
| 480 | +it("ignores non-decimal and unsafe session write-lock env values", () => { |
| 481 | +expect( |
| 482 | +resolveSessionWriteLockOptions( |
| 483 | +{ |
| 484 | +session: { |
| 485 | +writeLock: { |
| 486 | +acquireTimeoutMs: 90_000, |
| 487 | +staleMs: 45_000, |
| 488 | +maxHoldMs: 30_000, |
| 489 | +}, |
| 490 | +}, |
| 491 | +}, |
| 492 | +{ |
| 493 | +env: { |
| 494 | +OPENCLAW_SESSION_WRITE_LOCK_ACQUIRE_TIMEOUT_MS: "1e3", |
| 495 | +OPENCLAW_SESSION_WRITE_LOCK_STALE_MS: "0x1000", |
| 496 | +OPENCLAW_SESSION_WRITE_LOCK_MAX_HOLD_MS: "9007199254740993", |
| 497 | +}, |
| 498 | +}, |
| 499 | +), |
| 500 | +).toEqual({ |
| 501 | +timeoutMs: 90_000, |
| 502 | +staleMs: 45_000, |
| 503 | +maxHoldMs: 30_000, |
| 504 | +}); |
| 505 | +}); |
| 506 | + |
| 507 | +it("allows explicit infinite acquire timeout but not infinite stale policy", () => { |
| 508 | +expect( |
| 509 | +resolveSessionWriteLockOptions(undefined, { |
| 510 | +env: { |
| 511 | +OPENCLAW_SESSION_WRITE_LOCK_ACQUIRE_TIMEOUT_MS: "Infinity", |
| 512 | +OPENCLAW_SESSION_WRITE_LOCK_STALE_MS: "Infinity", |
| 513 | +}, |
| 514 | +}), |
| 515 | +).toMatchObject({ |
| 516 | +timeoutMs: Number.POSITIVE_INFINITY, |
| 517 | +staleMs: 30 * 60 * 1000, |
| 518 | +}); |
| 519 | +}); |
| 520 | + |
480 | 521 | it("uses resolved stale policy when cleaning stale lock files", async () => { |
481 | 522 | const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-lock-policy-")); |
482 | 523 | const sessionsDir = path.join(root, "sessions"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。