Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

fix(cost): preserve healthy worker updates on rollout I/O errors (#2178)

Dipesh Babu35ff82b7900f
diff --git a/sdk/typescript/src/cost.ts b/sdk/typescript/src/cost.ts
index acce8e102..20b58e365 100644
--- a/sdk/typescript/src/cost.ts
+++ b/sdk/typescript/src/cost.ts
@@ -2293,7 +2293,8 @@ export class ScanCostTracker {
await readSessionUsage(path, session, repository, progressThread);
} catch (error) {
if (session.threadId === null) {
- if (!observeHealthySessions || !isDeniedLogRead(error)) throw error;
+ if (!observeHealthySessions || !isBlockedLogRead(error))
+ throw error;
blocked ??= [session, error];
}
unreadable.set(session, error);
@@ -3676,10 +3677,12 @@ function subtractTokenUsage(
});
}
-function isDeniedLogRead(error: unknown): boolean {
+function isBlockedLogRead(error: unknown): boolean {
return (
isRecord(error) &&
- (error["code"] === "EACCES" || error["code"] === "EPERM") &&
+ (error["code"] === "EACCES" ||
+ error["code"] === "EPERM" ||
+ error["code"] === "EIO") &&
(error["syscall"] === "open" || error["syscall"] === "read")
);
}
diff --git a/sdk/typescript/tests-ts/cost.test.ts b/sdk/typescript/tests-ts/cost.test.ts
index 414231e7b..0f80fc295 100644
--- a/sdk/typescript/tests-ts/cost.test.ts
+++ b/sdk/typescript/tests-ts/cost.test.ts
@@ -3177,7 +3177,7 @@ describe("live scan cost tracking", () => {
},
);
- test.each(["EACCES", "EPERM"])(
+ test.each(["EACCES", "EPERM", "EIO"])(
"stops at the first unidentified log whose stat fails with %s on each poll",
async (code) => {
const home = await codexHome();
@@ -3222,6 +3222,8 @@ describe("live scan cost tracking", () => {
["EPERM", false, "observe"],
["EACCES", true, "both"],
["EPERM", false, "both"],
+ ["EIO", false, "observe"],
+ ["EIO", false, "both"],
] as const)(
"retains and retries a %s worker when its parent appears later (identified: %j, tracking: %s)",
async (code, identified, tracking) => {