@replayio-app-building/netlify-recorder 0.43.0 → 0.44.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.d.ts +14 -0
- package/dist/index.js +8 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -95,6 +95,14 @@ interface BlobData {
|
|
|
95
95
|
endTime: number;
|
|
96
96
|
/** The response returned to the client, used to detect replay mismatches. */
|
|
97
97
|
handlerResponse?: HandlerResponse$1;
|
|
98
|
+
/**
|
|
99
|
+
* The request ID of the first request handled by this module instance.
|
|
100
|
+
* When this differs from the current request's ID, the execution environment
|
|
101
|
+
* was reused (warm start) and module-level state from the original request
|
|
102
|
+
* may have affected this request's behavior (e.g. in-memory caches skipping
|
|
103
|
+
* network calls).
|
|
104
|
+
*/
|
|
105
|
+
originalRequestId?: string;
|
|
98
106
|
}
|
|
99
107
|
interface FinishRequestCallbacks {
|
|
100
108
|
/**
|
|
@@ -178,6 +186,12 @@ interface FinishRequestOptions {
|
|
|
178
186
|
* sent to the client in the `X-Replay-Request-Id` header.
|
|
179
187
|
*/
|
|
180
188
|
requestId?: string;
|
|
189
|
+
/**
|
|
190
|
+
* The request ID of the first request handled by this module instance.
|
|
191
|
+
* Included in the blob data to link warm-start requests back to the
|
|
192
|
+
* cold-start request that populated module-level caches.
|
|
193
|
+
*/
|
|
194
|
+
originalRequestId?: string;
|
|
181
195
|
}
|
|
182
196
|
/**
|
|
183
197
|
* Called at the end of the handler execution.
|
package/dist/index.js
CHANGED
|
@@ -730,7 +730,8 @@ async function finishRequest(requestContext, callbacks, response, options) {
|
|
|
730
730
|
handlerResponse: {
|
|
731
731
|
statusCode: response.statusCode ?? response.status ?? 0,
|
|
732
732
|
body: typeof response.body === "string" ? response.body : void 0
|
|
733
|
-
}
|
|
733
|
+
},
|
|
734
|
+
originalRequestId: options?.originalRequestId
|
|
734
735
|
};
|
|
735
736
|
const blobData = redactBlobData(rawBlobData);
|
|
736
737
|
const blobContent = JSON.stringify(blobData);
|
|
@@ -761,9 +762,13 @@ async function finishRequest(requestContext, callbacks, response, options) {
|
|
|
761
762
|
|
|
762
763
|
// src/createRecordingRequestHandler.ts
|
|
763
764
|
import crypto2 from "crypto";
|
|
765
|
+
var _originalRequestId = null;
|
|
764
766
|
function createRecordingRequestHandler(handler, options) {
|
|
765
767
|
return async (event, context) => {
|
|
766
768
|
const requestId = crypto2.randomUUID();
|
|
769
|
+
if (_originalRequestId === null) {
|
|
770
|
+
_originalRequestId = requestId;
|
|
771
|
+
}
|
|
767
772
|
return runInRequestContext(requestId, async () => {
|
|
768
773
|
const reqContext = startRequest(event);
|
|
769
774
|
let response;
|
|
@@ -786,7 +791,7 @@ function createRecordingRequestHandler(handler, options) {
|
|
|
786
791
|
statusCode: 500,
|
|
787
792
|
body: JSON.stringify({ error: errorMessage })
|
|
788
793
|
};
|
|
789
|
-
const finishOpts2 = { ...options, requestId };
|
|
794
|
+
const finishOpts2 = { ...options, requestId, originalRequestId: _originalRequestId };
|
|
790
795
|
const ctx2 = context;
|
|
791
796
|
if (ctx2 && typeof ctx2.waitUntil === "function") {
|
|
792
797
|
ctx2.waitUntil(
|
|
@@ -825,7 +830,7 @@ function createRecordingRequestHandler(handler, options) {
|
|
|
825
830
|
"X-Replay-Request-Id": requestId
|
|
826
831
|
}
|
|
827
832
|
};
|
|
828
|
-
const finishOpts = { ...options, requestId };
|
|
833
|
+
const finishOpts = { ...options, requestId, originalRequestId: _originalRequestId };
|
|
829
834
|
const ctx = context;
|
|
830
835
|
if (ctx && typeof ctx.waitUntil === "function") {
|
|
831
836
|
ctx.waitUntil(
|