@replayio-app-building/netlify-recorder 0.55.0 → 0.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +14 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -984,7 +984,7 @@ async function finishRequest(requestContext, callbacks, response, options) {
984
984
  body: typeof response.body === "string" ? response.body : void 0
985
985
  },
986
986
  originalRequestId: options?.originalRequestId,
987
- packageVersion: "0.55.0"
987
+ packageVersion: "0.56.0"
988
988
  };
989
989
  const blobData = redactBlobData(rawBlobData);
990
990
  const blobContent = JSON.stringify(blobData);
@@ -1113,6 +1113,7 @@ function createRecordingRequestHandler(handler, options) {
1113
1113
  }
1114
1114
 
1115
1115
  // src/createRequestRecording.ts
1116
+ import { gunzipSync } from "zlib";
1116
1117
  async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, precedingBlobs) {
1117
1118
  let blobData;
1118
1119
  if (typeof blobUrlOrData === "string") {
@@ -1122,7 +1123,9 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1122
1123
  `Failed to download blob from ${blobUrlOrData}: ${response.status}`
1123
1124
  );
1124
1125
  }
1125
- blobData = await response.json();
1126
+ const buf = Buffer.from(await response.arrayBuffer());
1127
+ const json = buf[0] === 31 && buf[1] === 139 ? gunzipSync(buf).toString("utf-8") : buf.toString("utf-8");
1128
+ blobData = JSON.parse(json);
1126
1129
  } else {
1127
1130
  blobData = blobUrlOrData;
1128
1131
  }
@@ -1545,6 +1548,8 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
1545
1548
  }
1546
1549
 
1547
1550
  // src/backendRequests.ts
1551
+ import { gzipSync } from "zlib";
1552
+ import { createHash } from "crypto";
1548
1553
  import { UTApi } from "uploadthing/server";
1549
1554
  async function backendRequestsEnsureTable(sql) {
1550
1555
  await sql`
@@ -1671,10 +1676,15 @@ async function uploadBlobData(blobData, requestId) {
1671
1676
  );
1672
1677
  }
1673
1678
  const utapi = new UTApi({ token });
1674
- const blob = new Blob([blobData], { type: "application/json" });
1675
- const file = Object.assign(blob, { name: `blob-${requestId}.json` });
1679
+ const compressed = gzipSync(Buffer.from(blobData, "utf-8"));
1680
+ const blob = new Blob([compressed], { type: "application/gzip" });
1681
+ const file = Object.assign(blob, { name: `blob-${requestId}.json.gz` });
1676
1682
  const result = await utapi.uploadFiles(file);
1677
1683
  if (result.error || !result.data?.ufsUrl) {
1684
+ const tokenHash = createHash("sha256").update(token).digest("hex").slice(0, 8);
1685
+ console.error(
1686
+ `netlify-recorder: uploadBlobData failed for request ${requestId} (token length=${token.length}, hash=${tokenHash}\u2026): ${JSON.stringify(result.error ?? "no URL returned")}`
1687
+ );
1678
1688
  throw new Error(
1679
1689
  `Failed to upload blob data for request ${requestId}: ${JSON.stringify(result.error ?? "no URL returned")}`
1680
1690
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replayio-app-building/netlify-recorder",
3
- "version": "0.55.0",
3
+ "version": "0.56.0",
4
4
  "description": "Capture and replay Netlify function executions as Replay recordings",
5
5
  "type": "module",
6
6
  "exports": {