From d9fe149185798be8b128d541492c04adde394033 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 05:05:20 +0000 Subject: [PATCH 1/4] Initial plan From f65217789cf99eae0c722c409b4dfefa7d9f0445 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 05:10:27 +0000 Subject: [PATCH 2/4] fix(ui): handle gzip content-encoding in HTML reporter metadata Check for gzip magic numbers instead of Content-Type header to determine if decompression is needed. This fixes the issue where browsers auto-decompress responses with Content-Encoding: gzip, causing double decompression errors. Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com> --- packages/ui/client/composables/client/static.ts | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/ui/client/composables/client/static.ts b/packages/ui/client/composables/client/static.ts index fb839d0fdba5..ac5fb347bfbe 100644 --- a/packages/ui/client/composables/client/static.ts +++ b/packages/ui/client/composables/client/static.ts @@ -98,17 +98,16 @@ export function createStaticClient(): VitestClient { async function registerMetadata() { const res = await fetch(window.METADATA_PATH!) - const contentType = res.headers.get('content-type')?.toLowerCase() || '' - if ( - contentType.includes('application/gzip') - || contentType.includes('application/x-gzip') - ) { - const compressed = new Uint8Array(await res.arrayBuffer()) - const decompressed = strFromU8(decompressSync(compressed)) + const content = new Uint8Array(await res.arrayBuffer()) + + // Check for gzip magic numbers (0x1f 0x8b) to determine if content is compressed + // This handles cases where Content-Encoding: gzip causes browser to auto-decompress + if (content.length >= 2 && content[0] === 0x1F && content[1] === 0x8B) { + const decompressed = strFromU8(decompressSync(content)) metadata = parse(decompressed) as HTMLReportMetadata } else { - metadata = parse(await res.text()) as HTMLReportMetadata + metadata = parse(strFromU8(content)) as HTMLReportMetadata } const event = new Event('open') ctx.ws.dispatchEvent(event) From c87d8ec212f010e4dd26ba228dd509d5b5ebe6b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 17 Dec 2025 05:19:26 +0000 Subject: [PATCH 3/4] fix(ui): clarify comment about incorrect server behavior Update comment to explicitly mention that static servers setting Content-Encoding: gzip for .gz files is incorrect behavior, and that browser auto-decompression is expected. Co-authored-by: hi-ogawa <4232207+hi-ogawa@users.noreply.github.com> --- packages/ui/client/composables/client/static.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/ui/client/composables/client/static.ts b/packages/ui/client/composables/client/static.ts index ac5fb347bfbe..e0254a8f98ef 100644 --- a/packages/ui/client/composables/client/static.ts +++ b/packages/ui/client/composables/client/static.ts @@ -100,8 +100,9 @@ export function createStaticClient(): VitestClient { const res = await fetch(window.METADATA_PATH!) const content = new Uint8Array(await res.arrayBuffer()) - // Check for gzip magic numbers (0x1f 0x8b) to determine if content is compressed - // This handles cases where Content-Encoding: gzip causes browser to auto-decompress + // Check for gzip magic numbers (0x1f 0x8b) to determine if content is compressed. + // This handles cases where a static server incorrectly sets Content-Encoding: gzip + // for .gz files, causing the browser to auto-decompress before we receive the response. if (content.length >= 2 && content[0] === 0x1F && content[1] === 0x8B) { const decompressed = strFromU8(decompressSync(content)) metadata = parse(decompressed) as HTMLReportMetadata From 8b10b7ab5cf8f8529fc92ac380b6465916fd3127 Mon Sep 17 00:00:00 2001 From: Hiroshi Ogawa Date: Wed, 17 Dec 2025 14:23:56 +0900 Subject: [PATCH 4/4] Update packages/ui/client/composables/client/static.ts --- packages/ui/client/composables/client/static.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/client/composables/client/static.ts b/packages/ui/client/composables/client/static.ts index e0254a8f98ef..2347ef420865 100644 --- a/packages/ui/client/composables/client/static.ts +++ b/packages/ui/client/composables/client/static.ts @@ -102,7 +102,7 @@ export function createStaticClient(): VitestClient { // Check for gzip magic numbers (0x1f 0x8b) to determine if content is compressed. // This handles cases where a static server incorrectly sets Content-Encoding: gzip - // for .gz files, causing the browser to auto-decompress before we receive the response. + // for .gz files, causing the browser to auto-decompress before we process the raw gzip data. if (content.length >= 2 && content[0] === 0x1F && content[1] === 0x8B) { const decompressed = strFromU8(decompressSync(content)) metadata = parse(decompressed) as HTMLReportMetadata