Skip to content

Commit ea505e1

Browse files
mo4islonaclaude
andcommitted
fix(portal): make S1 fast+deterministic — pin a small chunk instead of streaming a 500k-block chunk
S1 flaked on CI with a 30s timeout. Root cause: the test left PORTAL_CHUNK_BLOCKS at its 500k default, and the stub server streams one block per request — so draining the first serviced chunk took ~45k real localhost round-trips (~7s idle, ballooning past the timeout under CI load). The test's own comment ("one block at its start") shows small chunks were the intent. Pin PORTAL_CHUNK_BLOCKS=100 for S1: the same read-ahead + eviction accounting is exercised in a handful of requests. S1 goes from ~7-19s (30s timeout under load) to ~320ms, stable across repeated runs under multi-core CPU load. Also reword the testTimeout comment to match reality (the 30s is general headroom for the real-backoff head-probe tests + coverage instrumentation, not portal-shell). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent bf50171 commit ea505e1

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

portal/portal-shell.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,11 @@ test('S1: rows return to baseline after chunks settle and are evicted (no double
668668
// fetches settle: the gate's row count must equal exactly the LIVE cache's rows — here 0, because the
669669
// final far interval has no data and everything behind was evicted + freed via per-fetch tokens.
670670
process.env.PORTAL_READAHEAD = '2';
671+
// Pin a SMALL chunk (default is 500k). The stub server streams one block per request, so a 500k-block
672+
// chunk means ~45k real localhost round-trips to drain the first chunk — ~7s idle, and it blows past
673+
// the test timeout on a loaded CI box (the S1 flake). A 100-block chunk exercises the same read-ahead
674+
// + eviction accounting in a handful of requests. (PORTAL_CHUNK_FIXED is already set in beforeEach.)
675+
process.env.PORTAL_CHUNK_BLOCKS = '100';
671676
const srv = http.createServer((req, res) => {
672677
let body = '';
673678
req.on('data', (c) => {
@@ -727,5 +732,6 @@ test('S1: rows return to baseline after chunks settle and are evicted (no double
727732
} finally {
728733
srv.close();
729734
delete process.env.PORTAL_READAHEAD;
735+
delete process.env.PORTAL_CHUNK_BLOCKS;
730736
}
731737
});

portal/vite.portal.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export default defineConfig({
1414
'src/sync-historical/portal*.test.ts',
1515
'src/sync-historical/realtime*.test.ts',
1616
],
17-
// 30s (not 15s): portal-shell's heavy fake-timer/retry tests run ~15s under coverage
18-
// instrumentation, which flakes on a loaded CI server. Give per-test headroom.
17+
// 30s (up from 15s): headroom for the few tests that exercise REAL backoff (head-probe retry) and
18+
// coverage instrumentation on a loaded CI box. The old 15s was tight enough to flake there.
1919
testTimeout: 30000,
2020
// Coverage is scoped to the Portal layer (the whole diff vs upstream ponder). Inert on a plain
2121
// `--test` run: it only activates under `--coverage` (see scripts/sync-upstream.sh --coverage),

0 commit comments

Comments
 (0)