spana-test 0.8.0 → 0.9.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 (55) hide show
  1. package/dist/agent/index.d.ts +2 -2
  2. package/dist/agent/index.js +5 -5
  3. package/dist/{app-CgbLADmF.d.ts → app-DSh1ejLh.d.ts} +97 -22
  4. package/dist/{chunk-NS2HLJO4.js → chunk-2KRVN4WN.js} +3 -3
  5. package/dist/{chunk-AJCSETN6.js → chunk-3UVSUVHW.js} +619 -174
  6. package/dist/chunk-3UVSUVHW.js.map +1 -0
  7. package/dist/{chunk-3FXDOTFI.js → chunk-ALPQES3J.js} +187 -36
  8. package/dist/chunk-ALPQES3J.js.map +1 -0
  9. package/dist/{chunk-PMXSU5MS.js → chunk-FP6PVHHR.js} +2 -2
  10. package/dist/{chunk-WKVU24B6.js → chunk-IGTK5MHB.js} +4 -4
  11. package/dist/{chunk-2T4K7BJ3.js → chunk-JZZ2W2XH.js} +3 -2
  12. package/dist/chunk-JZZ2W2XH.js.map +1 -0
  13. package/dist/{chunk-SNL4X67N.js → chunk-UEWZ2EXL.js} +352 -111
  14. package/dist/chunk-UEWZ2EXL.js.map +1 -0
  15. package/dist/{chunk-QP4MDUBY.js → chunk-VP6V4XEJ.js} +2 -2
  16. package/dist/{chunk-RKYKRGHB.js → chunk-Z6K4QQAR.js} +128 -6
  17. package/dist/chunk-Z6K4QQAR.js.map +1 -0
  18. package/dist/cli.js +9 -9
  19. package/dist/config-loader-F5YAY7RP.js +9 -0
  20. package/dist/{daemon-manager-DDYQITPD.js → daemon-manager-2EQDVUVM.js} +8 -2
  21. package/dist/{doctor-command-HEQQOYUR.js → doctor-command-YTCQ2SC7.js} +4 -4
  22. package/dist/{flow-Md5xLwbX.d.ts → flow-CSMwD9Fh.d.ts} +1 -1
  23. package/dist/gherkin/steps.d.ts +2 -2
  24. package/dist/index.d.ts +38 -8
  25. package/dist/index.js +25 -9
  26. package/dist/index.js.map +1 -1
  27. package/dist/{installer-IYGMG7LS.js → installer-5UHTYQTB.js} +3 -3
  28. package/dist/{server-JPNH33MX.js → server-4YLBAZEM.js} +6 -6
  29. package/dist/{server-4PEREPHY.js → server-IS4K5FCT.js} +2 -2
  30. package/dist/{session-D9e30RVS.d.ts → session-CgvT-Oso.d.ts} +3 -1
  31. package/dist/{session-V4PYJXNB.js → session-K7FCRKOC.js} +6 -6
  32. package/dist/{studio-command-JOIFCOHC.js → studio-command-RFPV2DS7.js} +2 -2
  33. package/dist/{test-command-JCO2HPYI.js → test-command-UEJG5AI6.js} +11 -9
  34. package/dist/test-command-UEJG5AI6.js.map +1 -0
  35. package/native/win32-x64/spana_native.dll +0 -0
  36. package/package.json +1 -1
  37. package/dist/chunk-2T4K7BJ3.js.map +0 -1
  38. package/dist/chunk-3FXDOTFI.js.map +0 -1
  39. package/dist/chunk-AJCSETN6.js.map +0 -1
  40. package/dist/chunk-RKYKRGHB.js.map +0 -1
  41. package/dist/chunk-SNL4X67N.js.map +0 -1
  42. package/dist/config-loader-5FU45FXK.js +0 -9
  43. package/dist/test-command-JCO2HPYI.js.map +0 -1
  44. /package/dist/{chunk-NS2HLJO4.js.map → chunk-2KRVN4WN.js.map} +0 -0
  45. /package/dist/{chunk-PMXSU5MS.js.map → chunk-FP6PVHHR.js.map} +0 -0
  46. /package/dist/{chunk-WKVU24B6.js.map → chunk-IGTK5MHB.js.map} +0 -0
  47. /package/dist/{chunk-QP4MDUBY.js.map → chunk-VP6V4XEJ.js.map} +0 -0
  48. /package/dist/{config-loader-5FU45FXK.js.map → config-loader-F5YAY7RP.js.map} +0 -0
  49. /package/dist/{daemon-manager-DDYQITPD.js.map → daemon-manager-2EQDVUVM.js.map} +0 -0
  50. /package/dist/{doctor-command-HEQQOYUR.js.map → doctor-command-YTCQ2SC7.js.map} +0 -0
  51. /package/dist/{installer-IYGMG7LS.js.map → installer-5UHTYQTB.js.map} +0 -0
  52. /package/dist/{server-JPNH33MX.js.map → server-4YLBAZEM.js.map} +0 -0
  53. /package/dist/{server-4PEREPHY.js.map → server-IS4K5FCT.js.map} +0 -0
  54. /package/dist/{session-V4PYJXNB.js.map → session-K7FCRKOC.js.map} +0 -0
  55. /package/dist/{studio-command-JOIFCOHC.js.map → studio-command-RFPV2DS7.js.map} +0 -0
@@ -16,7 +16,7 @@ import {
16
16
  parseWebHierarchy,
17
17
  resolveNetworkConditions,
18
18
  setupUiAutomator2
19
- } from "./chunk-AJCSETN6.js";
19
+ } from "./chunk-3UVSUVHW.js";
20
20
  import {
21
21
  CdpDomChannel,
22
22
  DriverError,
@@ -24,15 +24,15 @@ import {
24
24
  buildDomFindElementScript,
25
25
  createSpanaBridgeChannel,
26
26
  makeElectrobunDriver
27
- } from "./chunk-SNL4X67N.js";
27
+ } from "./chunk-UEWZ2EXL.js";
28
28
  import {
29
29
  setupWDA
30
- } from "./chunk-QP4MDUBY.js";
30
+ } from "./chunk-VP6V4XEJ.js";
31
31
  import {
32
32
  getHealthyWarmDaemon,
33
33
  registerWarmDaemon,
34
34
  updateWarmDaemonSession
35
- } from "./chunk-RKYKRGHB.js";
35
+ } from "./chunk-Z6K4QQAR.js";
36
36
  import {
37
37
  connectPhysicalDevice,
38
38
  ensureAppInstalled,
@@ -383,6 +383,7 @@ function parseCdpKeyDescriptor(rawKey) {
383
383
  modifiers
384
384
  };
385
385
  }
386
+ var UPLOAD_ATTACH_TIMEOUT_MS = 3e4;
386
387
  var RESOURCE_BLOCK_PATTERNS = {
387
388
  image: ["*.png", "*.jpg", "*.jpeg", "*.gif", "*.webp", "*.svg", "*.ico", "*.avif"],
388
389
  font: ["*.woff", "*.woff2", "*.ttf", "*.otf", "*.eot"],
@@ -430,6 +431,7 @@ function makeLightweightCdpDriver(options) {
430
431
  const jsErrors = [];
431
432
  const routeRules = [];
432
433
  let fetchInterceptEnabled = false;
434
+ let activeResponseWatchers = 0;
433
435
  let nextTabSeq = 1;
434
436
  let downloadDir;
435
437
  const completedDownloads = [];
@@ -618,28 +620,84 @@ function makeLightweightCdpDriver(options) {
618
620
  cdpChannel.onEvent("Target.attachedToTarget", (params) => {
619
621
  const targetInfo = params?.targetInfo;
620
622
  const childSid = params?.sessionId;
623
+ const waiting = Boolean(params?.waitingForDebugger);
621
624
  if (targetInfo?.type === "iframe" && typeof childSid === "string") {
622
625
  cdpChannel.addChildSession(childSid, {
623
626
  targetId: typeof targetInfo.targetId === "string" ? targetInfo.targetId : void 0,
624
627
  url: typeof targetInfo.url === "string" ? targetInfo.url : void 0
625
628
  });
626
- void cdpChannel.sendCommand("Runtime.enable", {}, childSid).catch(() => {
627
- });
628
- if (useInjectedRuntime) {
629
- void cdpChannel.sendCommand(
630
- "Page.addScriptToEvaluateOnNewDocument",
631
- { source: SPANA_INJECTED_RUNTIME_SCRIPT },
632
- childSid
633
- ).catch(() => {
629
+ void (async () => {
630
+ await cdpChannel.sendCommand("Runtime.enable", {}, childSid).catch(() => {
631
+ });
632
+ if (useInjectedRuntime) {
633
+ await cdpChannel.sendCommand(
634
+ "Page.addScriptToEvaluateOnNewDocument",
635
+ { source: SPANA_INJECTED_RUNTIME_SCRIPT },
636
+ childSid
637
+ ).catch(() => {
638
+ });
639
+ }
640
+ if (waiting) {
641
+ await cdpChannel.sendCommand("Runtime.runIfWaitingForDebugger", {}, childSid).catch(() => {
642
+ });
643
+ }
644
+ })();
645
+ } else if (targetInfo?.type === "page" && typeof childSid === "string" && activeSlot && targetInfo.browserContextId === activeSlot.browserContextId) {
646
+ const alreadyTracked = activeSlot.tabs.some(
647
+ (t) => t.sessionId === childSid || t.targetId === targetInfo.targetId
648
+ );
649
+ if (!alreadyTracked) {
650
+ activeSlot.tabs.push({
651
+ tabId: `tab-${nextTabSeq++}`,
652
+ targetId: String(targetInfo.targetId ?? ""),
653
+ sessionId: childSid
634
654
  });
635
655
  }
656
+ void (async () => {
657
+ const setupCalls = [
658
+ cdpChannel.sendCommand("Page.enable", {}, childSid).catch(() => {
659
+ }),
660
+ cdpChannel.sendCommand("Runtime.enable", {}, childSid).catch(() => {
661
+ })
662
+ ];
663
+ if (activeResponseWatchers > 0) {
664
+ setupCalls.push(cdpChannel.sendCommand("Network.enable", {}, childSid).catch(() => {
665
+ }));
666
+ }
667
+ if (useInjectedRuntime) {
668
+ setupCalls.push(
669
+ cdpChannel.sendCommand(
670
+ "Page.addScriptToEvaluateOnNewDocument",
671
+ { source: SPANA_INJECTED_RUNTIME_SCRIPT },
672
+ childSid
673
+ ).catch(() => {
674
+ })
675
+ );
676
+ }
677
+ await Promise.all(setupCalls);
678
+ if (waiting) {
679
+ await cdpChannel.sendCommand("Runtime.runIfWaitingForDebugger", {}, childSid).catch(() => {
680
+ });
681
+ }
682
+ })();
683
+ } else if (waiting && typeof childSid === "string") {
684
+ void cdpChannel.sendCommand("Runtime.runIfWaitingForDebugger", {}, childSid).catch(() => {
685
+ });
636
686
  }
637
687
  });
638
688
  cdpChannel.onEvent("Target.detachedFromTarget", (params) => {
639
689
  if (typeof params?.sessionId === "string") {
640
690
  cdpChannel.removeChildSession(params.sessionId);
691
+ if (activeSlot) {
692
+ activeSlot.tabs = activeSlot.tabs.filter((t) => t.sessionId !== params.sessionId);
693
+ }
641
694
  }
642
695
  });
696
+ cdpChannel.onEvent("Page.javascriptDialogOpening", (params, sid) => {
697
+ const accept = params?.type === "beforeunload";
698
+ void cdpChannel.sendCommand("Page.handleJavaScriptDialog", { accept }, sid ?? null).catch(() => {
699
+ });
700
+ });
643
701
  cdpChannel.setFrameOffsetResolver(async (child) => {
644
702
  if (!child.targetId) return { x: 0, y: 0 };
645
703
  try {
@@ -711,6 +769,20 @@ function makeLightweightCdpDriver(options) {
711
769
  });
712
770
  });
713
771
  if (useContexts) {
772
+ yield* Effect2.tryPromise({
773
+ try: () => cdpChannel.sendCommand(
774
+ "Target.setAutoAttach",
775
+ {
776
+ autoAttach: true,
777
+ waitForDebuggerOnStart: true,
778
+ flatten: true,
779
+ filter: [{ type: "page" }]
780
+ },
781
+ null
782
+ ).catch(() => {
783
+ }),
784
+ catch: () => new DriverError({ message: "Failed to enable Target.setAutoAttach" })
785
+ }).pipe(Effect2.catchAll(() => Effect2.void));
714
786
  activeSlot = yield* Effect2.tryPromise({
715
787
  try: () => createContextSlot(options.storageState),
716
788
  catch: (e) => new DriverError({ message: `Failed to create direct CDP browser context: ${e}` })
@@ -1133,12 +1205,39 @@ function makeLightweightCdpDriver(options) {
1133
1205
  waitForResponse: (matcher, waitOpts) => Effect2.tryPromise({
1134
1206
  try: async () => {
1135
1207
  const timeoutMs = waitOpts?.timeout ?? 15e3;
1136
- const targetSid = activeSlot?.sessionId;
1137
- await cdpChannel.sendCommand("Network.enable").catch(() => {
1138
- });
1208
+ const slotSessions = () => {
1209
+ if (!activeSlot) return null;
1210
+ const set = /* @__PURE__ */ new Set([activeSlot.sessionId]);
1211
+ for (const t of activeSlot.tabs) {
1212
+ if (t.sessionId) set.add(t.sessionId);
1213
+ }
1214
+ return set;
1215
+ };
1216
+ const matchesActiveSlot = (sid) => {
1217
+ const allowed = slotSessions();
1218
+ if (!allowed || !sid) return true;
1219
+ return allowed.has(sid);
1220
+ };
1221
+ activeResponseWatchers += 1;
1222
+ const initialSessions = slotSessions();
1223
+ if (initialSessions && initialSessions.size > 0) {
1224
+ await Promise.all(
1225
+ Array.from(initialSessions).map(
1226
+ (sid) => cdpChannel.sendCommand("Network.enable", {}, sid).catch(() => {
1227
+ })
1228
+ )
1229
+ );
1230
+ } else {
1231
+ await cdpChannel.sendCommand("Network.enable").catch(() => {
1232
+ });
1233
+ }
1139
1234
  const requestMethods = /* @__PURE__ */ new Map();
1140
1235
  return await new Promise((resolve, reject) => {
1236
+ let cleaned = false;
1141
1237
  const cleanup = () => {
1238
+ if (cleaned) return;
1239
+ cleaned = true;
1240
+ activeResponseWatchers = Math.max(0, activeResponseWatchers - 1);
1142
1241
  clearTimeout(timer);
1143
1242
  offReq();
1144
1243
  offRes();
@@ -1148,13 +1247,16 @@ function makeLightweightCdpDriver(options) {
1148
1247
  reject(new Error(`Timed out waiting for response after ${timeoutMs}ms`));
1149
1248
  }, timeoutMs);
1150
1249
  const offReq = cdpChannel.onEvent("Network.requestWillBeSent", (params, sid) => {
1151
- if (targetSid && sid && sid !== targetSid) return;
1250
+ if (!matchesActiveSlot(sid)) return;
1152
1251
  if (params?.requestId && params?.request?.method) {
1153
- requestMethods.set(String(params.requestId), String(params.request.method));
1252
+ requestMethods.set(
1253
+ `${sid ?? ""}:${String(params.requestId)}`,
1254
+ String(params.request.method)
1255
+ );
1154
1256
  }
1155
1257
  });
1156
1258
  const offRes = cdpChannel.onEvent("Network.responseReceived", (params, sid) => {
1157
- if (targetSid && sid && sid !== targetSid) return;
1259
+ if (!matchesActiveSlot(sid)) return;
1158
1260
  const resp = params?.response;
1159
1261
  if (!resp) return;
1160
1262
  const requestId = String(params?.requestId ?? "");
@@ -1163,16 +1265,19 @@ function makeLightweightCdpDriver(options) {
1163
1265
  for (const [k, v] of Object.entries(rawHeaders)) {
1164
1266
  headers[k.toLowerCase()] = String(v);
1165
1267
  }
1268
+ const responseSid = sid ?? activeSlot?.sessionId ?? null;
1166
1269
  const info = {
1167
1270
  url: String(resp.url ?? ""),
1168
1271
  status: Number(resp.status ?? 0),
1169
1272
  statusText: String(resp.statusText ?? ""),
1170
1273
  headers,
1171
- method: requestMethods.get(requestId),
1274
+ method: requestMethods.get(`${sid ?? ""}:${requestId}`),
1172
1275
  body: async () => {
1173
- const bodyRes = await cdpChannel.sendCommand("Network.getResponseBody", {
1174
- requestId
1175
- });
1276
+ const bodyRes = await cdpChannel.sendCommand(
1277
+ "Network.getResponseBody",
1278
+ { requestId },
1279
+ responseSid
1280
+ );
1176
1281
  if (bodyRes?.base64Encoded && bodyRes.body) {
1177
1282
  return Buffer.from(bodyRes.body, "base64").toString("utf8");
1178
1283
  }
@@ -1340,14 +1445,24 @@ function makeLightweightCdpDriver(options) {
1340
1445
  await cdpChannel.sendCommand("DOM.enable");
1341
1446
  await cdpChannel.sendCommand("DOM.getDocument", { depth: 0 }).catch(() => {
1342
1447
  });
1343
- const evalRes = await cdpChannel.sendCommand("Runtime.evaluate", {
1344
- expression: expr,
1345
- returnByValue: false
1346
- });
1347
- const objectId = evalRes?.result?.objectId;
1448
+ const envTimeout = Number(process.env["SPANA_UPLOAD_TIMEOUT_MS"]);
1449
+ const attachTimeout = Number.isFinite(envTimeout) && envTimeout > 0 ? envTimeout : UPLOAD_ATTACH_TIMEOUT_MS;
1450
+ const deadline = Date.now() + attachTimeout;
1451
+ let objectId;
1452
+ while (Date.now() < deadline) {
1453
+ const evalRes = await cdpChannel.sendCommand("Runtime.evaluate", {
1454
+ expression: expr,
1455
+ returnByValue: false
1456
+ });
1457
+ if (evalRes?.result?.objectId) {
1458
+ objectId = evalRes.result.objectId;
1459
+ break;
1460
+ }
1461
+ await new Promise((r) => setTimeout(r, 50));
1462
+ }
1348
1463
  if (!objectId) {
1349
1464
  throw new Error(
1350
- `No matching file input found for selector ${JSON.stringify(selector)}`
1465
+ `No matching file input found within ${attachTimeout}ms for selector ${JSON.stringify(selector)}`
1351
1466
  );
1352
1467
  }
1353
1468
  const nodeRes = await cdpChannel.sendCommand("DOM.requestNode", { objectId }).catch(() => ({}));
@@ -1508,7 +1623,8 @@ function buildEngineConfig(appId, platform, parseFn, config, screenSize) {
1508
1623
  initialPollInterval: config.defaults?.initialPollInterval,
1509
1624
  tapMode: config.defaults?.tapMode,
1510
1625
  platform,
1511
- failFastWhenIdle: config.defaults?.failFastWhenIdle
1626
+ failFastWhenIdle: config.defaults?.failFastWhenIdle,
1627
+ actionStableFrames: config.defaults?.actionStableFrames
1512
1628
  },
1513
1629
  waitForIdleTimeout: config.defaults?.waitForIdleTimeout,
1514
1630
  typingDelay: config.defaults?.typingDelay,
@@ -2071,7 +2187,7 @@ async function buildLocalIOSRuntime(config, targetDevice, resolveFromConfig) {
2071
2187
  });
2072
2188
  }
2073
2189
  if (signing?.teamId) {
2074
- const { setupWDAForDevice } = await import("./installer-IYGMG7LS.js");
2190
+ const { setupWDAForDevice } = await import("./installer-5UHTYQTB.js");
2075
2191
  const wdaPort2 = allocatePort(8100);
2076
2192
  conn = await setupWDAForDevice(
2077
2193
  physicalDevice2.udid,
@@ -2868,6 +2984,22 @@ function createStepRecorder(driver, artifactConfig, flowName, platform) {
2868
2984
 
2869
2985
  // src/report/classify-error.ts
2870
2986
  var TAG_KEY = "_tag";
2987
+ var FIBER_FAILURE_CAUSE_SYMBOL = /* @__PURE__ */ Symbol.for("effect/Runtime/FiberFailure/Cause");
2988
+ function unwrapTaggedError(error) {
2989
+ if (!error || typeof error !== "object") return {};
2990
+ const obj = error;
2991
+ if (typeof obj[TAG_KEY] === "string") {
2992
+ return obj;
2993
+ }
2994
+ const cause = obj[FIBER_FAILURE_CAUSE_SYMBOL];
2995
+ if (cause && typeof cause === "object") {
2996
+ const inner = cause["error"] ?? cause["defect"];
2997
+ if (inner && typeof inner === "object" && typeof inner[TAG_KEY] === "string") {
2998
+ return inner;
2999
+ }
3000
+ }
3001
+ return obj;
3002
+ }
2871
3003
  function selectorHint(selector) {
2872
3004
  if (selector && typeof selector === "object") {
2873
3005
  const s = selector;
@@ -3062,7 +3194,7 @@ var heuristicRules = [
3062
3194
  suggestion: "The operation timed out. Try increasing `defaults.waitTimeout` in spana.config.ts."
3063
3195
  },
3064
3196
  {
3065
- pattern: /not found|not visible/,
3197
+ pattern: /not found|not visible|not fillable|covered by/,
3066
3198
  category: (msg) => categorizeElementFailure(msg),
3067
3199
  suggestion: (_error, msg) => {
3068
3200
  if (msg.includes("scroll(s) toward")) {
@@ -3115,11 +3247,11 @@ function categorize(error) {
3115
3247
  return { category: "unknown" };
3116
3248
  }
3117
3249
  function classifyError(error, opts) {
3118
- const tagged = error;
3250
+ const tagged = unwrapTaggedError(error);
3119
3251
  const { category, suggestion } = categorize(tagged);
3120
3252
  const extracted = extractCodeFrame(error.stack, opts?.flowFilePath) ?? extractCodeFrame(opts?.fallbackStack, opts?.flowFilePath);
3121
3253
  return {
3122
- message: error.message,
3254
+ message: tagged.message ?? error.message,
3123
3255
  stack: error.stack,
3124
3256
  category,
3125
3257
  suggestion,
@@ -3254,8 +3386,9 @@ function createFailureBundle(flowName, platform, steps, error, artifactDir, atta
3254
3386
  nearbyAlternatives
3255
3387
  };
3256
3388
  }
3389
+ const shellQuote = (value) => `'${value.replaceAll("'", `'\\''`)}'`;
3257
3390
  const flowFile = flowPath ?? `flows/${flowName.replaceAll(" ", "-")}.flow.ts`;
3258
- const reproCommand = `spana test ${flowFile} --platform ${platform} --grep '${flowName}'`;
3391
+ const reproCommand = `spana test ${shellQuote(flowFile)} --platform ${platform} --grep ${shellQuote(flowName)}`;
3259
3392
  let runtimeDiagnostics;
3260
3393
  const consolePath = join4(artifactDir, "console-logs.json");
3261
3394
  const jsErrPath = join4(artifactDir, "js-errors.json");
@@ -3313,6 +3446,14 @@ function createFailureBundle(flowName, platform, steps, error, artifactDir, atta
3313
3446
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
3314
3447
  failedStep,
3315
3448
  lastPassedStep,
3449
+ steps: steps.map((s, index) => ({
3450
+ index,
3451
+ command: s.command,
3452
+ selector: s.selector ?? null,
3453
+ durationMs: s.durationMs,
3454
+ status: s.status,
3455
+ ...s.error !== void 0 ? { error: s.error } : {}
3456
+ })),
3316
3457
  error: {
3317
3458
  message: error.message,
3318
3459
  category: error.category,
@@ -3754,8 +3895,9 @@ async function runParallel(config) {
3754
3895
 
3755
3896
  // src/core/worker-pool.ts
3756
3897
  import { spawn as spawn3 } from "child_process";
3757
- import { readFile as readFile2, unlink } from "fs/promises";
3898
+ import { mkdir, readFile as readFile2, unlink, writeFile as writeFile2 } from "fs/promises";
3758
3899
  import { createServer } from "http";
3900
+ import { dirname } from "path";
3759
3901
  var DEFAULT_MAX_WORKERS_PER_PROCESS = 8;
3760
3902
  async function startSharedFlowQueueServer(orderedFlowNames) {
3761
3903
  const queue = [...orderedFlowNames];
@@ -3846,6 +3988,13 @@ function partitionFlowsAcrossProcesses(items, processCount, options) {
3846
3988
  }
3847
3989
  return buckets.map((bucket) => bucket.toSorted((a, b) => a.idx - b.idx).map((e) => e.item)).filter((b) => b.length > 0);
3848
3990
  }
3991
+ async function writeWorkerProcessReport(results, env = process.env) {
3992
+ const reportPath = env["SPANA_WORKER_REPORT_PATH"];
3993
+ if (!reportPath) return null;
3994
+ await mkdir(dirname(reportPath), { recursive: true });
3995
+ await writeFile2(reportPath, JSON.stringify({ results }, null, 2), "utf8");
3996
+ return reportPath;
3997
+ }
3849
3998
  async function defaultReadJsonReport(reportJsonPath) {
3850
3999
  let content;
3851
4000
  try {
@@ -3939,6 +4088,7 @@ async function runMultiProcessPool(options) {
3939
4088
 
3940
4089
  export {
3941
4090
  launchDirectCdpBrowser,
4091
+ UPLOAD_ATTACH_TIMEOUT_MS,
3942
4092
  makeLightweightCdpDriver,
3943
4093
  resolveWebEngine,
3944
4094
  speculativelyPrelaunchWebBrowser,
@@ -3964,6 +4114,7 @@ export {
3964
4114
  createRemoteFlowClaimer,
3965
4115
  planProcessPool,
3966
4116
  partitionFlowsAcrossProcesses,
4117
+ writeWorkerProcessReport,
3967
4118
  runMultiProcessPool
3968
4119
  };
3969
- //# sourceMappingURL=chunk-3FXDOTFI.js.map
4120
+ //# sourceMappingURL=chunk-ALPQES3J.js.map