Tests: fix two CI flakes seen on main
CI / Lint (eslint) (pull_request) Successful in 27s
CI / Test (jest) (pull_request) Successful in 1m4s
CI / Security (npm audit) (pull_request) Successful in 39s
CI / Integration (api) (pull_request) Successful in 4m18s
CI / Scan (secrets, workflows, shell) (pull_request) Successful in 3m50s
CI / UI screenshots (before/after) (pull_request) Successful in 10s
CI / UI (playwright) (pull_request) Successful in 2m39s
CI / Deploy (pull_request) Skipped
CI / Deploy worker (pull_request) Skipped
CI / Notify (pull_request) Skipped
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Successful in 1m15s
CI / Lint (eslint) (push) Successful in 1m20s
CI / Security (npm audit) (push) Successful in 27s
CI / Integration (api) (push) Successful in 3m42s
CI / Scan (secrets, workflows, shell) (push) Successful in 3m11s
CI / UI (playwright) (push) Successful in 2m38s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Skipped

- calculateNextRun interval: bounded by the clock before and after the
  call (its first use loads cron-parser, which took 30 s once on a loaded
  runner and broke the fixed 1 s tolerance).
- Integration helper: retry a GET once when a pooled keep-alive connection
  is reset (ECONNRESET as the server closes it); writes are never retried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-23 00:57:53 -05:00
1 parent 1a031515e7
commit 6d289a3bce
2 files changed
+17 -3

No files matched your search

+12 -1
View File
@@ -18,11 +18,22 @@ const SSO = {
}; };
async function api(method, url, { headers = {}, body } = {}) { async function api(method, url, { headers = {}, body } = {}) {
const res = await fetch(BASE + url, { const send = () => fetch(BASE + url, {
method, method,
headers: { ...(body !== undefined ? { 'Content-Type': 'application/json' } : {}), ...headers }, headers: { ...(body !== undefined ? { 'Content-Type': 'application/json' } : {}), ...headers },
body: body !== undefined ? JSON.stringify(body) : undefined, body: body !== undefined ? JSON.stringify(body) : undefined,
}); });
let res;
try {
res = await send();
} catch (e) {
// A pooled keep-alive connection can be closed by the server (5 s idle timeout) just
// as the client reuses it: ECONNRESET. Retry once, but only reads; a write might
// already have taken effect.
const reset = e && e.cause && e.cause.code === 'ECONNRESET';
if (method !== 'GET' || !reset) throw e;
res = await send();
}
const text = await res.text(); const text = await res.text();
let json = null; let json = null;
try { json = JSON.parse(text); } catch { /* not JSON */ } try { json = JSON.parse(text); } catch { /* not JSON */ }
+5 -2
View File
@@ -123,10 +123,13 @@ describe('evalCondition', () => {
describe('calculateNextRun', () => { describe('calculateNextRun', () => {
test('interval: returns a date ~N minutes in the future', () => { test('interval: returns a date ~N minutes in the future', () => {
// Bounded by the clock before and after the call: its first use loads cron-parser,
// which took 30 s once on a loaded CI runner and broke a fixed 1 s tolerance.
const before = Date.now(); const before = Date.now();
const result = calculateNextRun('interval', '30'); const result = calculateNextRun('interval', '30');
expect(result.getTime()).toBeGreaterThanOrEqual(before + 30 * 60000 - 100); const after = Date.now();
expect(result.getTime()).toBeLessThanOrEqual(before + 30 * 60000 + 1000); expect(result.getTime()).toBeGreaterThanOrEqual(before + 30 * 60000);
expect(result.getTime()).toBeLessThanOrEqual(after + 30 * 60000);
}); });
test('interval: throws on non-positive value', () => { test('interval: throws on non-positive value', () => {