@mostra/runtime 0.4.0 → 0.5.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/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { a as uninstallService, i as serviceStatus, n as startInstance, o as checkPlatform, r as installService, s as resolveHomePath, t as runtimeVersion } from "./instance-DxcGEQj_.js";
2
+ import { a as uninstallService, i as serviceStatus, n as startInstance, o as checkPlatform, r as installService, s as resolveHomePath, t as runtimeVersion } from "./instance-CYvNd7mP.js";
3
3
  import { s as realPath } from "./files-FygSJIzK.js";
4
4
  import { mkdirSync } from "node:fs";
5
5
  import { fileURLToPath } from "node:url";
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as startInstance, t as runtimeVersion } from "./instance-DxcGEQj_.js";
1
+ import { n as startInstance, t as runtimeVersion } from "./instance-CYvNd7mP.js";
2
2
  import { t as connectToSupervisor } from "./child-Chiavhdx.js";
3
3
  export { connectToSupervisor, runtimeVersion, startInstance };
@@ -10662,6 +10662,12 @@ function createLive(options) {
10662
10662
  const retryAt = /* @__PURE__ */ new Map();
10663
10663
  /** Versions whose producers stopped because their worker is parked, by version, to their artifact. */
10664
10664
  const parkedVersions = /* @__PURE__ */ new Map();
10665
+ /** Why each parked version parked: its sources' error names the last cause. */
10666
+ const parkCauses = /* @__PURE__ */ new Map();
10667
+ const parkError = (cause) => ({
10668
+ code: "MOSTRA_RUNTIME_WORKER_PARKED",
10669
+ message: `The artifact's server code keeps crashing, so its live sources stopped (${cause}).`
10670
+ });
10665
10671
  let timer;
10666
10672
  let scheduled = false;
10667
10673
  let stopped = false;
@@ -10760,6 +10766,10 @@ function createLive(options) {
10760
10766
  throw error;
10761
10767
  }
10762
10768
  } catch (error) {
10769
+ if (parkedVersions.has(versionId)) {
10770
+ if (failures.get(id)?.code !== "MOSTRA_RUNTIME_WORKER_PARKED") fail(artifactId, key, parkError(parkCauses.get(versionId) ?? "its last start failed"));
10771
+ return;
10772
+ }
10763
10773
  const diagnostic = error instanceof RpcError ? error.diagnostic : void 0;
10764
10774
  fail(artifactId, key, {
10765
10775
  message: diagnostic?.message ?? String(error),
@@ -10915,14 +10925,18 @@ function createLive(options) {
10915
10925
  }
10916
10926
  },
10917
10927
  crashed(crash) {
10918
- for (const [id, producer] of running) if (producer.versionId === crash.versionId) running.delete(id);
10928
+ const ended = new Set(crash.liveKeys);
10929
+ for (const [id, producer] of running) {
10930
+ if (producer.versionId !== crash.versionId) continue;
10931
+ running.delete(id);
10932
+ ended.add(producer.key);
10933
+ }
10919
10934
  if (crash.parked) {
10920
- for (const key of crash.liveKeys) fail(crash.artifactId, key, {
10921
- code: "MOSTRA_RUNTIME_WORKER_PARKED",
10922
- message: `The artifact's server code keeps crashing, so its live sources stopped (${crash.cause}).`
10923
- });
10935
+ for (const source of described.get(crash.versionId) ?? []) ended.add(source.key);
10936
+ for (const key of ended) fail(crash.artifactId, key, parkError(crash.cause));
10924
10937
  retryAt.set(crash.versionId, Number.POSITIVE_INFINITY);
10925
10938
  parkedVersions.set(crash.versionId, crash.artifactId);
10939
+ parkCauses.set(crash.versionId, crash.cause);
10926
10940
  return;
10927
10941
  }
10928
10942
  retryAt.set(crash.versionId, Date.now() + crash.backoffMs);
@@ -10943,6 +10957,7 @@ function createLive(options) {
10943
10957
  for (const [versionId, owner] of parkedVersions) {
10944
10958
  if (owner !== artifactId) continue;
10945
10959
  parkedVersions.delete(versionId);
10960
+ parkCauses.delete(versionId);
10946
10961
  retryAt.delete(versionId);
10947
10962
  cleared = true;
10948
10963
  }
@@ -16663,4 +16678,4 @@ function sourceDirectory(path) {
16663
16678
  //#endregion
16664
16679
  export { uninstallService as a, serviceStatus as i, startInstance as n, checkPlatform as o, installService as r, resolveHomePath as s, runtimeVersion as t };
16665
16680
 
16666
- //# sourceMappingURL=instance-DxcGEQj_.js.map
16681
+ //# sourceMappingURL=instance-CYvNd7mP.js.map