@stim-cli/server 1.18.0 → 1.19.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.
@@ -66,7 +66,10 @@ public enum CoreSimulator {
66
66
  }
67
67
 
68
68
  static func simulatorKitPath(_ developerDir: String) -> String {
69
- "\(developerDir)/../SharedFrameworks/SimulatorKit.framework/SimulatorKit"
69
+ let shared = "\(developerDir)/../SharedFrameworks/SimulatorKit.framework/SimulatorKit"
70
+ let legacy = "\(developerDir)/Library/PrivateFrameworks/SimulatorKit.framework/SimulatorKit"
71
+ return FileManager.default.fileExists(atPath: shared) || !FileManager.default.fileExists(atPath: legacy)
72
+ ? shared : legacy
70
73
  }
71
74
 
72
75
  static let deviceSet: NSObject? = {
@@ -6535,9 +6535,11 @@ var DeviceHost = class {
6535
6535
  reconciling;
6536
6536
  draining = null;
6537
6537
  limits;
6538
+ debug;
6538
6539
  options;
6539
6540
  constructor(options) {
6540
6541
  this.options = options;
6542
+ this.debug = createDebugLog("server", { env: options.env });
6541
6543
  this.limits = {
6542
6544
  prepareMs: 3e5,
6543
6545
  offerMs: 3e4,
@@ -7687,6 +7689,15 @@ var DeviceHost = class {
7687
7689
  if (options.claim) clearClaimChild(options.claim);
7688
7690
  throw error;
7689
7691
  }
7692
+ const started = performance.now();
7693
+ const mode = "mode" in options.input && typeof options.input.mode === "string" ? options.input.mode : void 0;
7694
+ const diagnostic = (event, fields = {}) => this.debug.log(`device-host.worker.${event}`, {
7695
+ mode,
7696
+ workerPid: child.pid,
7697
+ ms: Math.round(performance.now() - started),
7698
+ ...fields
7699
+ });
7700
+ diagnostic("start", { timeoutMs: options.timeoutMs });
7690
7701
  let identity = null;
7691
7702
  const output = [];
7692
7703
  let outputBytes = 0;
@@ -7709,7 +7720,14 @@ var DeviceHost = class {
7709
7720
  clearTimeout(killTimer);
7710
7721
  clearTimeout(finishTimer);
7711
7722
  clearTimeout(groupTimer);
7712
- const settled = closed && (!child.pid || !processGroupAlive(child.pid));
7723
+ const groupAlive = closed && child.pid ? processGroupAlive(child.pid) : null;
7724
+ const settled = closed && groupAlive !== true;
7725
+ diagnostic("settled", {
7726
+ closed,
7727
+ groupAlive,
7728
+ settled,
7729
+ cancelling
7730
+ });
7713
7731
  if (settled && options.claim) clearClaimChild(options.claim);
7714
7732
  let value = null;
7715
7733
  try {
@@ -7737,9 +7755,10 @@ var DeviceHost = class {
7737
7755
  process.kill(-child.pid, name);
7738
7756
  } catch {}
7739
7757
  };
7740
- const cancel = () => {
7758
+ const cancel = (reason = "requested") => {
7741
7759
  if (finished || cancelling) return;
7742
7760
  cancelling = true;
7761
+ diagnostic("cancel", { reason });
7743
7762
  notice ??= "Hosted worker was cancelled or exceeded its deadline.";
7744
7763
  signal("SIGTERM");
7745
7764
  killTimer = setTimeout(() => signal("SIGKILL"), this.limits.killGraceMs);
@@ -7749,15 +7768,15 @@ var DeviceHost = class {
7749
7768
  if (finished) return;
7750
7769
  if (!child.pid || !processGroupAlive(child.pid)) finish();
7751
7770
  else {
7752
- cancel();
7771
+ cancel("group-after-close");
7753
7772
  groupTimer = setTimeout(finishGroup, 25);
7754
7773
  }
7755
7774
  };
7756
- const timer = setTimeout(cancel, options.timeoutMs);
7775
+ const timer = setTimeout(() => cancel("deadline"), options.timeoutMs);
7757
7776
  child.stdout?.on("data", (chunk) => {
7758
7777
  if (outputBytes + chunk.length > options.maxOutputBytes) {
7759
7778
  notice = "Hosted worker output exceeded its bound.";
7760
- cancel();
7779
+ cancel("output-bound");
7761
7780
  } else {
7762
7781
  output.push(chunk);
7763
7782
  outputBytes += chunk.length;
@@ -7766,13 +7785,18 @@ var DeviceHost = class {
7766
7785
  child.stderr?.on("data", (chunk) => {
7767
7786
  stderr = (stderr + chunk.toString()).slice(-8192);
7768
7787
  });
7769
- child.stdin?.on("error", () => cancel());
7788
+ child.stdin?.on("error", () => cancel("stdin-error"));
7770
7789
  child.once("error", (error) => {
7790
+ diagnostic("error", { code: error.code });
7771
7791
  notice = error.message;
7772
7792
  closed = true;
7773
7793
  finishGroup();
7774
7794
  });
7775
- child.once("close", (code) => {
7795
+ child.once("close", (code, closeSignal) => {
7796
+ diagnostic("close", {
7797
+ code,
7798
+ signal: closeSignal
7799
+ });
7776
7800
  if (code !== 0) notice ??= stderr.trim() || `Hosted worker exited ${code}.`;
7777
7801
  closed = true;
7778
7802
  finishGroup();
@@ -7781,7 +7805,7 @@ var DeviceHost = class {
7781
7805
  if (!captured?.ok || child.pid === void 0) {
7782
7806
  notice = "The worker process identity could not be captured; no native request was sent.";
7783
7807
  child.kill("SIGKILL");
7784
- cancel();
7808
+ cancel("identity-unavailable");
7785
7809
  } else {
7786
7810
  identity = {
7787
7811
  pid: child.pid,
@@ -7792,7 +7816,7 @@ var DeviceHost = class {
7792
7816
  child.stdin?.end(JSON.stringify(options.input));
7793
7817
  } catch (error) {
7794
7818
  notice = error.message;
7795
- cancel();
7819
+ cancel("request-write");
7796
7820
  }
7797
7821
  }
7798
7822
  return {
@@ -4,6 +4,6 @@ const encode = (version) => version.split(".", 3).reduce((sum, part) => sum * 1e
4
4
  if (encode(process.versions.node) < encode("22.12.0")) {
5
5
  process.stderr.write(`STIM_NODE_UNSUPPORTED: stim-server needs Node 22.12.0 or later; this is Node ${process.versions.node} at ${process.execPath}. To run stim-server where a project pins an older Node, see https://stim.appandflow.com/docs/requirements#older-node-pins\n`);
6
6
  process.exitCode = 1;
7
- } else import("./stim-server-BR9FPA63.mjs");
7
+ } else import("./stim-server-DThEHaj6.mjs");
8
8
  //#endregion
9
9
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stim-cli/server",
3
- "version": "1.18.0",
3
+ "version": "1.19.0",
4
4
  "description": "Serves Stim status to paired clients over Tailscale, and runs reload and stop for clients granted control.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,8 +28,8 @@
28
28
  "./protocol.schema.json": "./dist/protocol.schema.json"
29
29
  },
30
30
  "dependencies": {
31
- "@stim-cli/core": "^1.18.0",
32
- "stim": "1.18.0",
31
+ "@stim-cli/core": "^1.19.0",
32
+ "stim": "1.19.0",
33
33
  "ws": "^8.21.3"
34
34
  },
35
35
  "devDependencies": {