This commit is contained in:
imccyu
2026-08-27 16:52:40 +08:00
parent 3f4a6a2698
commit 90cae21deb
2 changed files with 29 additions and 0 deletions
@@ -131,6 +131,9 @@ export function parseClientRuntimeCancelFrame(value: Record<string, unknown>): C
* @param value - Untrusted acknowledgement frame.
* @returns The validated acknowledgement frame.
*/
/* jscpd:ignore-start */
// Deliberately mirrors parseClientRuntimeCancelFrame: each wire parser spells
// out its own envelope literally instead of sharing a tag-parameterized helper.
export function parseClientRuntimeResponseAcknowledgedFrame(
value: Record<string, unknown>,
): ClientRuntimeResponseAcknowledgedFrame {
@@ -147,6 +150,7 @@ export function parseClientRuntimeResponseAcknowledgedFrame(
requestId: wireId<'ClientRuntimeRequestId'>(value.requestId, 'requestId'),
}
}
/* jscpd:ignore-end */
/**
* Parse and rebuild one Client-to-Worker Runtime response.
@@ -205,6 +205,31 @@ describe('Inspector Network domain', () => {
})
})
it('marks a failure after response headers truncated with the transport error', () => {
const store = new NetworkStore({ maxRetainedRequests: 10, maxJournalBytes: 1_024 })
const observed: unknown[] = []
const unsubscribe = store.subscribe((event) => { observed.push(event) })
store.append(source, [
...requestRecords('midstream', 'partial').slice(0, 3),
{
sequence: 4,
monotonicMs: 4,
topic: 'fetch/error',
payload: { requestId: 'midstream', message: 'socket reset', canceled: false },
},
])
expect(store.responseBody(requestId('midstream'))).toMatchObject({
bytes: Buffer.from('partial'),
truncated: true,
captureError: 'socket reset',
complete: true,
})
expect(observed.at(-1)).toMatchObject({ type: 'request-failed', errorText: 'socket reset', canceled: false })
unsubscribe()
store.dispose()
})
it('retains request capture metadata and isolates malformed observations', () => {
const store = new NetworkStore({ maxRetainedRequests: 10, maxJournalBytes: 1_024 })
const observed: unknown[] = []