Skip to content

Commit 9c606b2

Browse files
committed
👷 Do not store binary data in VCR, ever
1 parent 58edbb0 commit 9c606b2

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

‎packages/inference/src/utils/base64FromBytes.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

‎packages/inference/test/vcr.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { base64FromBytes } from "../src/utils/base64FromBytes";
21
import { isBackend, isFrontend } from "../src/utils/env-predicates";
32
import { omit } from "../src/utils/omit";
43

@@ -145,13 +144,13 @@ async function vcr(
145144
method: init.method,
146145
},
147146
response: {
148-
// Truncating the body to 30KB to avoid having huge files
149-
body:
150-
arrayBuffer.byteLength > 30_000
151-
? ""
152-
: isText
153-
? new TextDecoder().decode(arrayBuffer)
154-
: BASE64_PREFIX + base64FromBytes(new Uint8Array(arrayBuffer)),
147+
body: isText ? new TextDecoder().decode(arrayBuffer) : "",
148+
// // Alternative to also save binary data:
149+
// arrayBuffer.byteLength > 30_000
150+
// ? ""
151+
// : isText
152+
// ? new TextDecoder().decode(arrayBuffer)
153+
// : BASE64_PREFIX + base64FromBytes(new Uint8Array(arrayBuffer)),
155154
status: response.status,
156155
statusText: response.statusText,
157156
headers: Object.fromEntries(

0 commit comments

Comments
 (0)