@uipath/common 1.202.0 → 1.202.1-preview.167

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.
@@ -24,6 +24,23 @@ export type RetryHint = (typeof RETRY_HINTS)[number];
24
24
  export declare function isCliErrorCode(value: unknown): value is CliErrorCode;
25
25
  /** Narrow an arbitrary value to a {@link RetryHint}. See {@link isCliErrorCode}. */
26
26
  export declare function isRetryHint(value: unknown): value is RetryHint;
27
+ /**
28
+ * The `ErrorCode` an error carries, when it classified itself.
29
+ *
30
+ * Companion to `carriedInstructions` (error-handler): a thrower that knows its
31
+ * failure mode can say so, and the renderer uses it instead of defaulting to
32
+ * `unknown_error`. Duck-typed and validated for the same reason — the error may
33
+ * have crossed a bundle boundary, and an unrecognised string must not reach the
34
+ * envelope as a code no consumer can branch on.
35
+ *
36
+ * Lives here, beside {@link isCliErrorCode}, rather than next to
37
+ * `carriedInstructions`: error-handler reaches formatter type-only on purpose,
38
+ * and a runtime edge from there pulls this module's telemetry imports into the
39
+ * browser bundle, which cannot require node builtins.
40
+ */
41
+ export declare function carriedErrorCode(error: unknown): CliErrorCode | undefined;
42
+ /** The `Retry` hint an error carries. See {@link carriedErrorCode}. */
43
+ export declare function carriedRetry(error: unknown): RetryHint | undefined;
27
44
  /** Canonical string constants for {@link ResultType} values. */
28
45
  export declare const RESULTS: {
29
46
  readonly Success: "Success";
package/dist/index.js CHANGED
@@ -10662,18 +10662,56 @@ function isSyncFlushForced() {
10662
10662
  function isDrainableTelemetryProvider(provider) {
10663
10663
  return "drainPendingEnvelopes" in provider && typeof provider.drainPendingEnvelopes === "function";
10664
10664
  }
10665
- function spawnTelemetrySidecar(entryPath) {
10666
- const child = spawn(process.execPath, [entryPath, TELEMETRY_DRAIN_ARGV], {
10667
- cwd: getFileSystem().env.tmpdir(),
10668
- detached: true,
10665
+ async function spawnTelemetrySidecar(entryPath) {
10666
+ const cwd = getFileSystem().env.tmpdir();
10667
+ const isWindows = process.platform === "win32";
10668
+ const child = isWindows ? spawn(windowsShell(), windowsLauncherArgs(entryPath), {
10669
+ cwd,
10669
10670
  stdio: "ignore",
10670
- windowsHide: true
10671
+ windowsHide: true,
10672
+ windowsVerbatimArguments: true
10673
+ }) : spawn(process.execPath, [entryPath, TELEMETRY_DRAIN_ARGV], {
10674
+ cwd,
10675
+ detached: true,
10676
+ stdio: "ignore"
10671
10677
  });
10672
10678
  child.on("error", (error) => {
10673
10679
  logger.debug(`[Telemetry] sidecar spawn failed (spool kept for a later run): ${error.message}`);
10674
10680
  });
10681
+ if (isWindows) {
10682
+ await waitForWindowsLauncher(child);
10683
+ }
10675
10684
  child.unref();
10676
10685
  }
10686
+ var WINDOWS_LAUNCHER_TIMEOUT_MS = 3000;
10687
+ function waitForWindowsLauncher(child) {
10688
+ return new Promise((resolve2) => {
10689
+ const timer = setTimeout(resolve2, WINDOWS_LAUNCHER_TIMEOUT_MS);
10690
+ timer.unref();
10691
+ const settle = () => {
10692
+ clearTimeout(timer);
10693
+ resolve2();
10694
+ };
10695
+ child.on("exit", settle);
10696
+ child.on("error", settle);
10697
+ });
10698
+ }
10699
+ function windowsShell() {
10700
+ return process.env.ComSpec ?? "cmd.exe";
10701
+ }
10702
+ function windowsLauncherArgs(entryPath) {
10703
+ return [
10704
+ "/d",
10705
+ "/s",
10706
+ "/c",
10707
+ "start",
10708
+ '""',
10709
+ "/b",
10710
+ `"${process.execPath}"`,
10711
+ `"${entryPath}"`,
10712
+ TELEMETRY_DRAIN_ARGV
10713
+ ];
10714
+ }
10677
10715
  async function trySidecarHandoff(provider) {
10678
10716
  const entryPath = getTelemetrySidecarEntry();
10679
10717
  if (entryPath === undefined || isSyncFlushForced() || !isDrainableTelemetryProvider(provider)) {
@@ -10688,7 +10726,7 @@ async function trySidecarHandoff(provider) {
10688
10726
  if (spoolError) {
10689
10727
  logger.debug(`[Telemetry] spool write failed; dropping ${pending.envelopes.length} pending envelope(s): ${spoolError.message}`);
10690
10728
  } else {
10691
- const [spawnError] = catchError(() => spawnTelemetrySidecar(entryPath));
10729
+ const [spawnError] = await catchError(spawnTelemetrySidecar(entryPath));
10692
10730
  if (spawnError) {
10693
10731
  logger.debug(`[Telemetry] sidecar spawn failed; spool will be sent by a future run: ${spawnError.message}`);
10694
10732
  }
@@ -10765,6 +10803,18 @@ function isCliErrorCode(value) {
10765
10803
  function isRetryHint(value) {
10766
10804
  return typeof value === "string" && RETRY_HINT_VALUES.has(value);
10767
10805
  }
10806
+ function carriedErrorCode(error) {
10807
+ if (!error || typeof error !== "object")
10808
+ return;
10809
+ const code = error.errorCode;
10810
+ return isCliErrorCode(code) ? code : undefined;
10811
+ }
10812
+ function carriedRetry(error) {
10813
+ if (!error || typeof error !== "object")
10814
+ return;
10815
+ const retry = error.retry;
10816
+ return isRetryHint(retry) ? retry : undefined;
10817
+ }
10768
10818
  var RESULTS = {
10769
10819
  Success: "Success",
10770
10820
  Failure: "Failure",
@@ -13513,7 +13563,9 @@ export {
13513
13563
  buildOrchestratorUrl,
13514
13564
  buildSkillEventTelemetryAttribution,
13515
13565
  canPrompt,
13566
+ carriedErrorCode,
13516
13567
  carriedInstructions,
13568
+ carriedRetry,
13517
13569
  catchError,
13518
13570
  claimPendingSpoolFiles,
13519
13571
  classifiedFailure,
@@ -13684,4 +13736,4 @@ export {
13684
13736
  writeTelemetrySpoolFile
13685
13737
  };
13686
13738
 
13687
- //# debugId=E388413E446272F364756E2164756E21
13739
+ //# debugId=58E4DC863EA8483464756E2164756E21
@@ -71,7 +71,7 @@ export declare function telemetryInit(options?: TelemetryInitOptions): Promise<v
71
71
  * Deliver all buffered telemetry before the process exits.
72
72
  * Must be awaited on every exit path.
73
73
  *
74
- * Normally hands the buffered envelopes to a detached sidecar process (see
74
+ * Normally hands the buffered envelopes to a background sidecar process (see
75
75
  * {@link trySidecarHandoff}) so the exit is instant. Falls back to the
76
76
  * in-process flush — one ingestion round-trip, capped at
77
77
  * FLUSH_SHUTDOWN_TIMEOUT_MS — when the sidecar handoff isn't available or
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uipath/common",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "1.202.0",
4
+ "version": "1.202.1-preview.167",
5
5
  "description": "Common infrastructure needed by uip tools.",
6
6
  "repository": {
7
7
  "type": "git",
@@ -75,5 +75,5 @@
75
75
  "mihaigirleanu",
76
76
  "vlad-uipath"
77
77
  ],
78
- "gitHead": "23b5a7038ead7264439af18f8b807c7cc99a29d5"
78
+ "gitHead": "04e307035c95c9da5b9a2e04c6794f64f14fd9da"
79
79
  }