Skip to content

Commit 947b33e

Browse files
committed
visualizer: manually decompress gzip when needed
1 parent 0c708e9 commit 947b33e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

ui/src/components/Sim/hooks/worker.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ const createEventStream = async <T>(path: string, signal: AbortSignal): Promise<
1818
if (!res.body) {
1919
throw new Error("body not streamed");
2020
}
21+
let stream = res.body;
2122
if (path.endsWith('.gz')) {
2223
path = path.substring(0, path.length - 3);
24+
if (res.headers.get('Content-Encoding') !== 'gzip') {
25+
stream = stream.pipeThrough(new DecompressionStream('gzip'));
26+
}
2327
}
2428
const transform = path.endsWith('.cbor') ? createCborTransformer() : createJsonTransformer();
25-
return res.body.pipeThrough(transform) as unknown as ReadableStream<T>;
29+
return stream.pipeThrough(transform) as unknown as ReadableStream<T>;
2630
}
2731

2832
const createJsonTransformer = <T>(): TransformStream<Uint8Array, T> => {

0 commit comments

Comments
 (0)