@replayio-app-building/netlify-recorder 0.48.0 → 0.49.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 CHANGED
@@ -331,6 +331,10 @@ interface EnsureRequestRecordingOptions {
331
331
  * with the blob data URL from the stored request, updates the row to `"queued"`,
332
332
  * and returns `null`.
333
333
  *
334
+ * For warm-start requests, registers all preceding requests from the same
335
+ * module instance with the recorder service before triggering the recording,
336
+ * so the recorder can replay them to reconstruct module-level state.
337
+ *
334
338
  * This function is idempotent — calling it multiple times for the same request
335
339
  * is safe. Once the recording completes, subsequent calls return the recording ID.
336
340
  */
package/dist/index.js CHANGED
@@ -1587,6 +1587,19 @@ function remoteCallbacks(recorderUrl) {
1587
1587
  }
1588
1588
  };
1589
1589
  }
1590
+ async function backendRequestsListPreceding(sql, targetRequestId, originalRequestId) {
1591
+ const rows = await sql`
1592
+ SELECT id, blob_data_url, handler_path, commit_sha, branch_name, repository_url,
1593
+ original_request_id, status, recording_id, error_message, created_at, updated_at
1594
+ FROM backend_requests
1595
+ WHERE original_request_id = ${originalRequestId}
1596
+ AND id != ${targetRequestId}
1597
+ AND created_at <= (SELECT created_at FROM backend_requests WHERE id = ${targetRequestId})
1598
+ AND blob_data_url IS NOT NULL
1599
+ ORDER BY created_at ASC
1600
+ `;
1601
+ return rows;
1602
+ }
1590
1603
  async function ensureRequestRecording(sql, requestId, options) {
1591
1604
  const request = await backendRequestsGet(sql, requestId);
1592
1605
  if (!request) {
@@ -1599,6 +1612,30 @@ async function ensureRequestRecording(sql, requestId, options) {
1599
1612
  return null;
1600
1613
  }
1601
1614
  const recorderUrl = options.recorderUrl.replace(/\/+$/, "");
1615
+ const origReqId = request.original_request_id;
1616
+ if (origReqId && origReqId !== requestId) {
1617
+ const preceding = await backendRequestsListPreceding(sql, requestId, origReqId);
1618
+ if (preceding.length > 0) {
1619
+ await Promise.all(
1620
+ preceding.map(
1621
+ (req) => fetch(`${recorderUrl}/api/store-request`, {
1622
+ method: "POST",
1623
+ headers: { "Content-Type": "application/json" },
1624
+ body: JSON.stringify({
1625
+ requestId: req.id,
1626
+ blobDataUrl: req.blob_data_url,
1627
+ handlerPath: req.handler_path,
1628
+ commitSha: req.commit_sha,
1629
+ branchName: req.branch_name,
1630
+ repositoryUrl: req.repository_url ?? void 0,
1631
+ originalRequestId: req.original_request_id ?? void 0
1632
+ })
1633
+ }).catch(() => {
1634
+ })
1635
+ )
1636
+ );
1637
+ }
1638
+ }
1602
1639
  const res = await fetch(`${recorderUrl}/api/create-recording`, {
1603
1640
  method: "POST",
1604
1641
  headers: { "Content-Type": "application/json" },
@@ -1610,7 +1647,7 @@ async function ensureRequestRecording(sql, requestId, options) {
1610
1647
  branchName: request.branch_name,
1611
1648
  repositoryUrl: request.repository_url ?? void 0,
1612
1649
  webhookUrl: options.webhookUrl,
1613
- originalRequestId: request.original_request_id ?? void 0
1650
+ originalRequestId: origReqId ?? void 0
1614
1651
  })
1615
1652
  });
1616
1653
  if (!res.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@replayio-app-building/netlify-recorder",
3
- "version": "0.48.0",
3
+ "version": "0.49.0",
4
4
  "description": "Capture and replay Netlify function executions as Replay recordings",
5
5
  "type": "module",
6
6
  "exports": {