@replayio-app-building/netlify-recorder 0.35.0 → 0.36.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 +16 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -716,8 +716,8 @@ async function finishRequest(requestContext, callbacks, response, options) {
716
716
  startTime: requestContext.startTime,
717
717
  endTime: Date.now(),
718
718
  handlerResponse: {
719
- statusCode: response.statusCode,
720
- body: response.body
719
+ statusCode: response.statusCode ?? response.status ?? 0,
720
+ body: typeof response.body === "string" ? response.body : void 0
721
721
  }
722
722
  };
723
723
  const blobData = redactBlobData(rawBlobData);
@@ -756,7 +756,18 @@ function createRecordingRequestHandler(handler, options) {
756
756
  const reqContext = startRequest(event);
757
757
  let response;
758
758
  try {
759
- response = await handler(event, context);
759
+ const rawResponse = await handler(event, context);
760
+ if (rawResponse && typeof rawResponse.status === "number" && typeof rawResponse.text === "function") {
761
+ const v2 = rawResponse;
762
+ const bodyText = await v2.text();
763
+ response = {
764
+ statusCode: v2.status,
765
+ body: bodyText,
766
+ headers: v2.headers?.entries ? Object.fromEntries(v2.headers.entries()) : void 0
767
+ };
768
+ } else {
769
+ response = rawResponse;
770
+ }
760
771
  } catch (handlerErr) {
761
772
  const errorMessage = handlerErr instanceof Error ? handlerErr.message : String(handlerErr);
762
773
  const errorResponse = {
@@ -1094,8 +1105,8 @@ async function createRequestRecording(blobUrlOrData, handlerPath, requestInfo) {
1094
1105
  );
1095
1106
  }
1096
1107
  if (bodyMismatch) {
1097
- const capturedPreview = (blobData.handlerResponse.body ?? "").slice(0, 200);
1098
- const replayPreview = (replayResponse.body ?? "").slice(0, 200);
1108
+ const capturedPreview = String(blobData.handlerResponse.body ?? "").slice(0, 200);
1109
+ const replayPreview = String(replayResponse.body ?? "").slice(0, 200);
1099
1110
  details.push(
1100
1111
  `Body differs: captured=${JSON.stringify(capturedPreview)}, replay=${JSON.stringify(replayPreview)}`
1101
1112
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replayio-app-building/netlify-recorder",
3
- "version": "0.35.0",
3
+ "version": "0.36.0",
4
4
  "description": "Capture and replay Netlify function executions as Replay recordings",
5
5
  "type": "module",
6
6
  "exports": {