@replayio-app-building/netlify-recorder 0.22.0 → 0.23.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 +30 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -572,10 +572,37 @@ function createRecordingRequestHandler(handler, options) {
572
572
  let response;
573
573
  try {
574
574
  response = await handler(event, context);
575
- } catch (err) {
575
+ } catch (handlerErr) {
576
+ const errorMessage = handlerErr instanceof Error ? handlerErr.message : String(handlerErr);
577
+ const errorResponse = {
578
+ statusCode: 500,
579
+ body: JSON.stringify({ error: errorMessage })
580
+ };
581
+ const finishOpts2 = { ...options, requestId };
582
+ const ctx2 = context;
583
+ if (ctx2 && typeof ctx2.waitUntil === "function") {
584
+ ctx2.waitUntil(
585
+ finishRequest(reqContext, options.callbacks, errorResponse, finishOpts2).catch(
586
+ (finishErr) => {
587
+ console.error(
588
+ `netlify-recorder: background finishRequest failed after handler error (handler: ${options.handlerPath ?? "unknown"})`,
589
+ finishErr
590
+ );
591
+ }
592
+ )
593
+ );
594
+ } else {
595
+ await finishRequest(reqContext, options.callbacks, errorResponse, finishOpts2).catch(
596
+ (finishErr) => {
597
+ console.error(
598
+ `netlify-recorder: finishRequest failed after handler error (handler: ${options.handlerPath ?? "unknown"})`,
599
+ finishErr
600
+ );
601
+ }
602
+ );
603
+ }
576
604
  setCurrentRequestId(null);
577
- reqContext.cleanup();
578
- throw err;
605
+ throw handlerErr;
579
606
  }
580
607
  reqContext.cleanup();
581
608
  setCurrentRequestId(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replayio-app-building/netlify-recorder",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Capture and replay Netlify function executions as Replay recordings",
5
5
  "type": "module",
6
6
  "exports": {