@replayio-app-building/netlify-recorder 0.55.0 → 0.57.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.
- package/dist/index.js +13 -4
- 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.
|
|
987
|
+
packageVersion: "0.57.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
|
-
|
|
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,7 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo, p
|
|
|
1545
1548
|
}
|
|
1546
1549
|
|
|
1547
1550
|
// src/backendRequests.ts
|
|
1551
|
+
import { gzipSync } from "zlib";
|
|
1548
1552
|
import { UTApi } from "uploadthing/server";
|
|
1549
1553
|
async function backendRequestsEnsureTable(sql) {
|
|
1550
1554
|
await sql`
|
|
@@ -1671,10 +1675,15 @@ async function uploadBlobData(blobData, requestId) {
|
|
|
1671
1675
|
);
|
|
1672
1676
|
}
|
|
1673
1677
|
const utapi = new UTApi({ token });
|
|
1674
|
-
const
|
|
1675
|
-
const
|
|
1678
|
+
const compressed = gzipSync(Buffer.from(blobData, "utf-8"));
|
|
1679
|
+
const blob = new Blob([compressed], { type: "application/gzip" });
|
|
1680
|
+
const file = Object.assign(blob, { name: `blob-${requestId}.json.gz` });
|
|
1676
1681
|
const result = await utapi.uploadFiles(file);
|
|
1677
1682
|
if (result.error || !result.data?.ufsUrl) {
|
|
1683
|
+
const preview = token.length > 8 ? `${token.slice(0, 4)}\u2026${token.slice(-4)}` : "(short)";
|
|
1684
|
+
console.error(
|
|
1685
|
+
`netlify-recorder: uploadBlobData failed for request ${requestId} (token: ${preview}, length=${token.length}): ${JSON.stringify(result.error ?? "no URL returned")}`
|
|
1686
|
+
);
|
|
1678
1687
|
throw new Error(
|
|
1679
1688
|
`Failed to upload blob data for request ${requestId}: ${JSON.stringify(result.error ?? "no URL returned")}`
|
|
1680
1689
|
);
|