mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-11-07 23:01:29 -10:00
test(web-shell): pin the single-skip resync boundary and the stall threshold (#13277)
Two guards this branch added were only pinned from one side, so a plausible edit to either survived the whole suite. The end-of-stream resync for a connection that delivered nothing but skips needed two skips to be observed: `skippedTotal > 0` could become `> 1` with all 253 tests green. That mutant reintroduces the wedge this branch fixes, one frame narrower — a lone corrupt delta on a closing connection ends the stream normally, so the hook pauses 3s, resubscribes from the same cursor, and replays the same frame forever with a frozen transcript and no visible error. The new case also counts warnings, which is what tells the end-of-stream guard apart from the fail-closed name check producing the same single frame. The stall guard's threshold was pinned only from below: the test advanced 3s at a time until the error appeared, so any threshold from 3 to 8 passed while the design doc and the PR body both say the third consecutive stall. Advancing exactly one more cadence pins it from both sides, and pins the cadence with it. Test-only; no production change. Each assertion was verified red against `> 1`, `>= 2`, `>= 4`, a name-check-first mutant, and a removed end-of-stream warning. Refs #13184 (items 6 and 7). Co-authored-by: wenshao <[email protected]>
This commit is contained in:
1 parent
576689d073
commit
2a6879e648
2 files changed
+34
-6
No files matched your search
@@ -213,6 +213,35 @@ describe('JavaManagedAgentClient', () => {
|
||||
expect(isJavaAgentResyncRequired(frames[0]!)).toBe(true);
|
||||
});
|
||||
|
||||
it('resyncs when a connection delivers nothing but a single skipped frame', async () => {
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
||||
const client = new JavaManagedAgentClient({
|
||||
baseUrl: 'https://product.example',
|
||||
fetch: vi.fn<typeof fetch>().mockResolvedValue(
|
||||
// One skip is already one too many: nothing valid was delivered, so
|
||||
// retrying the same cursor replays this frame identically. The stream
|
||||
// ends normally here, so without the resync the hook reconnects every
|
||||
// 3s forever with a frozen transcript and no visible error.
|
||||
new Response(corrupt(2), { status: 200 }),
|
||||
),
|
||||
});
|
||||
|
||||
const frames = [];
|
||||
for await (const frame of client.streamEvents({
|
||||
sessionId: 'session-1',
|
||||
afterSequence: 1,
|
||||
})) {
|
||||
frames.push(frame);
|
||||
}
|
||||
|
||||
expect(frames).toHaveLength(1);
|
||||
expect(isJavaAgentResyncRequired(frames[0]!)).toBe(true);
|
||||
// The skip warning plus the end-of-stream resync warning: a resync from
|
||||
// the fail-closed name check would log once instead, so this pins which
|
||||
// guard produced the frame.
|
||||
expect(warn).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('resyncs on a corrupt action update frame instead of skipping it', async () => {
|
||||
vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
||||
const client = new JavaManagedAgentClient({
|
||||
|
||||
@@ -2005,13 +2005,12 @@ describe('useManagedSession', () => {
|
||||
await act(async () => {
|
||||
await vi.advanceTimersByTimeAsync(3000);
|
||||
});
|
||||
// The error must not fire on the first stalls.
|
||||
// The error must not fire on the first two stalls...
|
||||
expect(latest?.error).toBeUndefined();
|
||||
for (let round = 0; round < 6 && latest?.error === undefined; round++) {
|
||||
await act(async () => {
|
||||
await vi.advanceTimersByTimeAsync(3000);
|
||||
});
|
||||
}
|
||||
// ...and fires on exactly the third: one more 3s cadence, no slack.
|
||||
await act(async () => {
|
||||
await vi.advanceTimersByTimeAsync(3000);
|
||||
});
|
||||
expect(latest?.error).toMatch(/not advancing/);
|
||||
// The error is the only user-visible signal of the stall: it must
|
||||
// persist while the condition persists, not flash for one cadence.
|
||||
|
||||
Reference in new issue
Block a user