mirror of
https://github.com/morluto/rea
synced 2026-10-26 14:25:49 -04:00
fix(process): use monotonic time for provider execution budgets
This commit is contained in:
@@ -279,6 +279,6 @@ export const checkRecoveryDeadline = (
|
||||
signal?: AbortSignal,
|
||||
): void => {
|
||||
checkRecoveryCancellation(signal);
|
||||
if (Date.now() >= deadline)
|
||||
if (performance.now() >= deadline)
|
||||
throw new AnalysisTimeoutError(OPERATION, RECOVERY_LIMITS.timeoutMs);
|
||||
};
|
||||
|
||||
@@ -33,7 +33,7 @@ it("rejects an exhausted shared execution budget before launching the next comma
|
||||
arguments: ["--version"],
|
||||
cwd: "/tmp/unused",
|
||||
environment: {},
|
||||
deadline: Date.now() - 1,
|
||||
deadline: performance.now() - 1,
|
||||
launcher: async () => {
|
||||
throw new Error("An expired budget must not launch");
|
||||
},
|
||||
@@ -52,7 +52,7 @@ it("preserves caller cancellation before acquiring an expired execution budget",
|
||||
arguments: ["--version"],
|
||||
cwd: "/tmp/unused",
|
||||
environment: {},
|
||||
deadline: Date.now() - 1,
|
||||
deadline: performance.now() - 1,
|
||||
signal: AbortSignal.abort(),
|
||||
launcher: async () => {
|
||||
throw new Error("A cancelled request must not launch");
|
||||
@@ -86,7 +86,7 @@ const commandFixture = (
|
||||
arguments: ["--version"],
|
||||
cwd: "/tmp/unused",
|
||||
environment: {},
|
||||
deadline: Date.now() + 5_000,
|
||||
deadline: performance.now() + 5_000,
|
||||
launcher,
|
||||
},
|
||||
};
|
||||
@@ -140,7 +140,7 @@ it("enforces the shared deadline while exited output streams remain open", async
|
||||
});
|
||||
try {
|
||||
await expect(
|
||||
runWakaruCommand({ ...context, deadline: Date.now() + 50 }),
|
||||
runWakaruCommand({ ...context, deadline: performance.now() + 50 }),
|
||||
).rejects.toMatchObject({
|
||||
_tag: "AnalysisTimeoutError",
|
||||
operation: "recover_javascript_sources",
|
||||
|
||||
@@ -100,7 +100,7 @@ export class WakaruProvider implements JavaScriptRecoveryPort {
|
||||
let tree: SafeOutputTree | undefined;
|
||||
let failed: { readonly cause: unknown } | undefined;
|
||||
let execution: AnalysisExecution | undefined;
|
||||
const deadline = Date.now() + RECOVERY_LIMITS.timeoutMs;
|
||||
const deadline = performance.now() + RECOVERY_LIMITS.timeoutMs;
|
||||
try {
|
||||
checkRecoveryCancellation(options?.signal);
|
||||
const engine = await resolveWakaruCommand(this.environment);
|
||||
|
||||
Reference in New Issue
Block a user