From 441ebd0433db63bce529e95168e233c11382785b Mon Sep 17 00:00:00 2001 From: Chinesezjc Date: Wed, 19 Aug 2026 17:30:10 +0800 Subject: [PATCH] test(code-runtime-python): exempt the mid-drain settle branch from coverage The drain loop's `if (settled) break` needs the run to settle in the window between two queued frames. A file probe on the concurrent-replies case shows the queue does reach depth 11, but the wall clock never lands inside that window, so the branch is not schedulable from a test; a case written to force it passed without ever executing the line, so it is removed rather than left as coverage it does not provide. The branch carries a v8 ignore naming what is unreachable. --- packages/code-runtime/code-runtime-python/src/index.ts | 3 +++ .../code-runtime/code-runtime-python/tests/runtime.spec.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/packages/code-runtime/code-runtime-python/src/index.ts b/packages/code-runtime/code-runtime-python/src/index.ts index 096a0da2c1..9ac5ffae5a 100644 --- a/packages/code-runtime/code-runtime-python/src/index.ts +++ b/packages/code-runtime/code-runtime-python/src/index.ts @@ -1402,6 +1402,9 @@ export class PythonCodeRuntime extends CodeRuntime { draining = true try { while (replyQueue.length > 0) { + // Needs the run to settle between two queued frames. Measured queue + // depths reach 11 without the wall clock landing inside that window. + /* v8 ignore next -- see above; not schedulable from a test. */ if (settled) break const payload = replyQueue.shift() as ReplyMessage // Encode inside the loop, not up front: a queued reply the run no diff --git a/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts b/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts index acb8a61ff3..8f24ff47c5 100644 --- a/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts +++ b/packages/code-runtime/code-runtime-python/tests/runtime.spec.ts @@ -3892,6 +3892,7 @@ describe('PythonCodeRuntime — hostile peer', () => { expect(result.value).toBe(8 * chunk.length) }, 90_000) + it('bounds a flood of zero-byte log lines through the per-entry separator charge', async () => { // Blank print() lines carry zero content bytes; without the +1 separator // charge they would bypass maxLogBytes entirely and grow the retained