@@ -6,6 +6,7 @@ import { createHash } from "node:crypto";
|
6 | 6 | import { createReadStream, readFileSync, statSync } from "node:fs"; |
7 | 7 | import fs from "node:fs/promises"; |
8 | 8 | import { isDeepStrictEqual } from "node:util"; |
| 9 | +import { clampTimerTimeoutMs } from "@openclaw/normalization-core/number-coercion"; |
9 | 10 | import { normalizeStringEntries } from "@openclaw/normalization-core/string-normalization"; |
10 | 11 | import { |
11 | 12 | type OwnedSessionTranscriptPublishedEntry, |
@@ -875,6 +876,13 @@ function abortOwnerWaitReason(signal: AbortSignal): unknown {
|
875 | 876 | return abortReason(signal) ?? new Error("operation aborted", { cause: signal }); |
876 | 877 | } |
877 | 878 | |
| 879 | +function resolveSessionFileOwnerWaitTimeoutMs(timeoutMs: number | undefined): number | undefined { |
| 880 | +if (timeoutMs === undefined) { |
| 881 | +return undefined; |
| 882 | +} |
| 883 | +return clampTimerTimeoutMs(timeoutMs); |
| 884 | +} |
| 885 | + |
878 | 886 | function waitForSessionFileOwnerRelease(params: { |
879 | 887 | sessionFile: string; |
880 | 888 | entry: SessionFileOwnerEntry; |
@@ -909,17 +917,18 @@ function waitForSessionFileOwnerRelease(params: {
|
909 | 917 | cleanup(); |
910 | 918 | reject(toLintErrorObject(error, "Non-Error rejection")); |
911 | 919 | }; |
912 | | -if (params.timeoutMs !== undefined && Number.isFinite(params.timeoutMs)) { |
| 920 | +const timeoutMs = resolveSessionFileOwnerWaitTimeoutMs(params.timeoutMs); |
| 921 | +if (timeoutMs !== undefined) { |
913 | 922 | waiter.timer = setTimeout( |
914 | 923 | () => { |
915 | 924 | waiter.reject( |
916 | 925 | new EmbeddedAttemptSessionFileOwnerTimeoutError( |
917 | 926 | params.sessionFile, |
918 | | -params.timeoutMs ?? 0, |
| 927 | +timeoutMs, |
919 | 928 | ), |
920 | 929 | ); |
921 | 930 | }, |
922 | | -Math.max(1, Math.floor(params.timeoutMs)), |
| 931 | +timeoutMs, |
923 | 932 | ); |
924 | 933 | waiter.timer.unref?.(); |
925 | 934 | } |
|