imccyu il y a 3 semaines
Parent
commit
90cae21deb

+ 4 - 0
packages/experimental/inspector/src/shared/bridge/messages/runtime/frames.ts

@@ -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.

+ 25 - 0
packages/experimental/inspector/tests/network.host.spec.ts

@@ -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[] = []