Skip to content

Commit da43f67

Browse files
committed
fix(ops): fall back on empty-string env vars in killswitch
GitHub Actions passes unset repo variables as "" rather than undefined, so `??` would not fall through to defaults. `Number("")` is 0, which caused every metric to trip on the first manual run. Switch to `||` so both undefined and "" drop to the built-in defaults.
1 parent 602d153 commit da43f67

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

scripts/cost-killswitch.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ if (!ACCOUNT_ID || !API_TOKEN) {
2828
process.exit(2);
2929
}
3030

31+
// GitHub Actions passes undefined repo vars as "", so use || to fall through
32+
// to defaults on both empty string and undefined.
3133
const thresholds = {
32-
workerRequests: Number(process.env.DAILY_WORKER_REQUESTS ?? 1_000_000),
33-
d1RowsRead: Number(process.env.DAILY_D1_ROWS_READ ?? 10_000_000),
34-
doRequests: Number(process.env.DAILY_DO_REQUESTS ?? 500_000),
35-
doDurationSec: Number(process.env.DAILY_DO_DURATION_SEC ?? 100_000),
34+
workerRequests: Number(process.env.DAILY_WORKER_REQUESTS || 1_000_000),
35+
d1RowsRead: Number(process.env.DAILY_D1_ROWS_READ || 10_000_000),
36+
doRequests: Number(process.env.DAILY_DO_REQUESTS || 500_000),
37+
doDurationSec: Number(process.env.DAILY_DO_DURATION_SEC || 100_000),
3638
};
3739

3840
// UTC day window — CF billing resets at 00:00 UTC

0 commit comments

Comments
 (0)