@replayio-app-building/netlify-recorder 0.53.0 → 0.54.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 +17 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -34,6 +34,7 @@ function incrementCallIndex() {
34
34
  // src/interceptors/network.ts
35
35
  import http from "http";
36
36
  import https from "https";
37
+ import zlib from "zlib";
37
38
  import { Readable, Writable } from "stream";
38
39
  function isNeonQuery(obj) {
39
40
  return typeof obj === "object" && obj !== null && "query" in obj && "params" in obj;
@@ -138,7 +139,21 @@ function patchHttpModules(mode, calls, consumed, silent) {
138
139
  entry.requestBody = bodyChunks.length > 0 ? Buffer.concat(bodyChunks).toString("utf-8") : void 0;
139
140
  entry.responseStatus = res.statusCode ?? 0;
140
141
  entry.responseHeaders = responseHeaders;
141
- entry.responseBody = Buffer.concat(resChunks).toString("utf-8");
142
+ const raw = Buffer.concat(resChunks);
143
+ const encoding = (res.headers["content-encoding"] || "").toLowerCase();
144
+ try {
145
+ if (encoding === "gzip" || encoding === "x-gzip") {
146
+ entry.responseBody = zlib.gunzipSync(raw).toString("utf-8");
147
+ } else if (encoding === "deflate") {
148
+ entry.responseBody = zlib.inflateSync(raw).toString("utf-8");
149
+ } else if (encoding === "br") {
150
+ entry.responseBody = zlib.brotliDecompressSync(raw).toString("utf-8");
151
+ } else {
152
+ entry.responseBody = raw.toString("utf-8");
153
+ }
154
+ } catch {
155
+ entry.responseBody = raw.toString("utf-8");
156
+ }
142
157
  entry.timestamp = endTime;
143
158
  entry.endTime = endTime;
144
159
  entry.pending = false;
@@ -969,7 +984,7 @@ async function finishRequest(requestContext, callbacks, response, options) {
969
984
  body: typeof response.body === "string" ? response.body : void 0
970
985
  },
971
986
  originalRequestId: options?.originalRequestId,
972
- packageVersion: "0.53.0"
987
+ packageVersion: "0.54.0"
973
988
  };
974
989
  const blobData = redactBlobData(rawBlobData);
975
990
  const blobContent = JSON.stringify(blobData);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replayio-app-building/netlify-recorder",
3
- "version": "0.53.0",
3
+ "version": "0.54.0",
4
4
  "description": "Capture and replay Netlify function executions as Replay recordings",
5
5
  "type": "module",
6
6
  "exports": {