@codelia/runtime 0.1.30 → 0.1.32

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.cjs CHANGED
@@ -3064,7 +3064,8 @@ var runShellCommand = (command, options) => new Promise((resolve, reject) => {
3064
3064
  cwd: options.cwd,
3065
3065
  shell: true,
3066
3066
  stdio: ["ignore", "pipe", "pipe"],
3067
- signal: options.signal
3067
+ signal: options.signal,
3068
+ detached: process.platform !== "win32"
3068
3069
  });
3069
3070
  let stdout = "";
3070
3071
  let stderr = "";
@@ -3078,6 +3079,18 @@ var runShellCommand = (command, options) => new Promise((resolve, reject) => {
3078
3079
  if (timeoutHandle) clearTimeout(timeoutHandle);
3079
3080
  handler();
3080
3081
  };
3082
+ const terminate = (signal) => {
3083
+ if (process.platform !== "win32" && typeof child.pid === "number") {
3084
+ try {
3085
+ process.kill(-child.pid, signal);
3086
+ } catch {
3087
+ }
3088
+ }
3089
+ try {
3090
+ child.kill(signal);
3091
+ } catch {
3092
+ }
3093
+ };
3081
3094
  const killForBufferOverflow = () => {
3082
3095
  const error = Object.assign(
3083
3096
  new Error(
@@ -3091,10 +3104,7 @@ var runShellCommand = (command, options) => new Promise((resolve, reject) => {
3091
3104
  signal: "SIGTERM"
3092
3105
  }
3093
3106
  );
3094
- try {
3095
- child.kill("SIGTERM");
3096
- } catch {
3097
- }
3107
+ terminate("SIGTERM");
3098
3108
  finish(() => reject(error));
3099
3109
  };
3100
3110
  const consumeChunk = (chunk, stream) => {
@@ -3160,15 +3170,22 @@ var runShellCommand = (command, options) => new Promise((resolve, reject) => {
3160
3170
  });
3161
3171
  timeoutHandle = setTimeout(() => {
3162
3172
  timedOut = true;
3163
- try {
3164
- child.kill("SIGTERM");
3165
- } catch {
3166
- }
3167
- setTimeout(() => {
3168
- try {
3169
- if (!child.killed) child.kill("SIGKILL");
3170
- } catch {
3173
+ const timeoutError = Object.assign(
3174
+ new Error(
3175
+ `Command timed out after ${Math.trunc(options.timeoutMs / 1e3)}s`
3176
+ ),
3177
+ {
3178
+ code: "ETIMEDOUT",
3179
+ stdout,
3180
+ stderr,
3181
+ killed: true,
3182
+ signal: "SIGTERM"
3171
3183
  }
3184
+ );
3185
+ terminate("SIGTERM");
3186
+ finish(() => reject(timeoutError));
3187
+ setTimeout(() => {
3188
+ terminate("SIGKILL");
3172
3189
  }, 2e3).unref();
3173
3190
  }, options.timeoutMs);
3174
3191
  });
@@ -8844,7 +8861,8 @@ var runShellWithUserShell = async (command, options) => {
8844
8861
  const child = (0, import_node_child_process5.spawn)(shellPath, ["-lc", command], {
8845
8862
  cwd: options.cwd,
8846
8863
  stdio: ["ignore", "pipe", "pipe"],
8847
- signal: options.signal
8864
+ signal: options.signal,
8865
+ detached: process.platform !== "win32"
8848
8866
  });
8849
8867
  let stdout = "";
8850
8868
  let stderr = "";
@@ -8858,6 +8876,18 @@ var runShellWithUserShell = async (command, options) => {
8858
8876
  if (timeoutHandle) clearTimeout(timeoutHandle);
8859
8877
  handler();
8860
8878
  };
8879
+ const terminate = (sig) => {
8880
+ if (process.platform !== "win32" && typeof child.pid === "number") {
8881
+ try {
8882
+ process.kill(-child.pid, sig);
8883
+ } catch {
8884
+ }
8885
+ }
8886
+ try {
8887
+ child.kill(sig);
8888
+ } catch {
8889
+ }
8890
+ };
8861
8891
  const consumeChunk = (chunk, stream) => {
8862
8892
  const text = chunk.toString("utf8");
8863
8893
  totalBytes += Buffer.byteLength(text, "utf8");
@@ -8874,10 +8904,7 @@ var runShellWithUserShell = async (command, options) => {
8874
8904
  signal: "SIGTERM"
8875
8905
  }
8876
8906
  );
8877
- try {
8878
- child.kill("SIGTERM");
8879
- } catch {
8880
- }
8907
+ terminate("SIGTERM");
8881
8908
  finish(() => reject(error));
8882
8909
  return;
8883
8910
  }
@@ -8924,15 +8951,22 @@ var runShellWithUserShell = async (command, options) => {
8924
8951
  });
8925
8952
  timeoutHandle = setTimeout(() => {
8926
8953
  timedOut = true;
8927
- try {
8928
- child.kill("SIGTERM");
8929
- } catch {
8930
- }
8931
- setTimeout(() => {
8932
- try {
8933
- if (!child.killed) child.kill("SIGKILL");
8934
- } catch {
8954
+ const timeoutError = Object.assign(
8955
+ new Error(
8956
+ `Command timed out after ${Math.trunc(options.timeoutMs / 1e3)}s`
8957
+ ),
8958
+ {
8959
+ code: "ETIMEDOUT",
8960
+ stdout,
8961
+ stderr,
8962
+ killed: true,
8963
+ signal: "SIGTERM"
8935
8964
  }
8965
+ );
8966
+ terminate("SIGTERM");
8967
+ finish(() => reject(timeoutError));
8968
+ setTimeout(() => {
8969
+ terminate("SIGKILL");
8936
8970
  }, 2e3).unref();
8937
8971
  }, options.timeoutMs);
8938
8972
  });
package/dist/index.js CHANGED
@@ -3054,7 +3054,8 @@ var runShellCommand = (command, options) => new Promise((resolve, reject) => {
3054
3054
  cwd: options.cwd,
3055
3055
  shell: true,
3056
3056
  stdio: ["ignore", "pipe", "pipe"],
3057
- signal: options.signal
3057
+ signal: options.signal,
3058
+ detached: process.platform !== "win32"
3058
3059
  });
3059
3060
  let stdout = "";
3060
3061
  let stderr = "";
@@ -3068,6 +3069,18 @@ var runShellCommand = (command, options) => new Promise((resolve, reject) => {
3068
3069
  if (timeoutHandle) clearTimeout(timeoutHandle);
3069
3070
  handler();
3070
3071
  };
3072
+ const terminate = (signal) => {
3073
+ if (process.platform !== "win32" && typeof child.pid === "number") {
3074
+ try {
3075
+ process.kill(-child.pid, signal);
3076
+ } catch {
3077
+ }
3078
+ }
3079
+ try {
3080
+ child.kill(signal);
3081
+ } catch {
3082
+ }
3083
+ };
3071
3084
  const killForBufferOverflow = () => {
3072
3085
  const error = Object.assign(
3073
3086
  new Error(
@@ -3081,10 +3094,7 @@ var runShellCommand = (command, options) => new Promise((resolve, reject) => {
3081
3094
  signal: "SIGTERM"
3082
3095
  }
3083
3096
  );
3084
- try {
3085
- child.kill("SIGTERM");
3086
- } catch {
3087
- }
3097
+ terminate("SIGTERM");
3088
3098
  finish(() => reject(error));
3089
3099
  };
3090
3100
  const consumeChunk = (chunk, stream) => {
@@ -3150,15 +3160,22 @@ var runShellCommand = (command, options) => new Promise((resolve, reject) => {
3150
3160
  });
3151
3161
  timeoutHandle = setTimeout(() => {
3152
3162
  timedOut = true;
3153
- try {
3154
- child.kill("SIGTERM");
3155
- } catch {
3156
- }
3157
- setTimeout(() => {
3158
- try {
3159
- if (!child.killed) child.kill("SIGKILL");
3160
- } catch {
3163
+ const timeoutError = Object.assign(
3164
+ new Error(
3165
+ `Command timed out after ${Math.trunc(options.timeoutMs / 1e3)}s`
3166
+ ),
3167
+ {
3168
+ code: "ETIMEDOUT",
3169
+ stdout,
3170
+ stderr,
3171
+ killed: true,
3172
+ signal: "SIGTERM"
3161
3173
  }
3174
+ );
3175
+ terminate("SIGTERM");
3176
+ finish(() => reject(timeoutError));
3177
+ setTimeout(() => {
3178
+ terminate("SIGKILL");
3162
3179
  }, 2e3).unref();
3163
3180
  }, options.timeoutMs);
3164
3181
  });
@@ -8862,7 +8879,8 @@ var runShellWithUserShell = async (command, options) => {
8862
8879
  const child = spawn5(shellPath, ["-lc", command], {
8863
8880
  cwd: options.cwd,
8864
8881
  stdio: ["ignore", "pipe", "pipe"],
8865
- signal: options.signal
8882
+ signal: options.signal,
8883
+ detached: process.platform !== "win32"
8866
8884
  });
8867
8885
  let stdout = "";
8868
8886
  let stderr = "";
@@ -8876,6 +8894,18 @@ var runShellWithUserShell = async (command, options) => {
8876
8894
  if (timeoutHandle) clearTimeout(timeoutHandle);
8877
8895
  handler();
8878
8896
  };
8897
+ const terminate = (sig) => {
8898
+ if (process.platform !== "win32" && typeof child.pid === "number") {
8899
+ try {
8900
+ process.kill(-child.pid, sig);
8901
+ } catch {
8902
+ }
8903
+ }
8904
+ try {
8905
+ child.kill(sig);
8906
+ } catch {
8907
+ }
8908
+ };
8879
8909
  const consumeChunk = (chunk, stream) => {
8880
8910
  const text = chunk.toString("utf8");
8881
8911
  totalBytes += Buffer.byteLength(text, "utf8");
@@ -8892,10 +8922,7 @@ var runShellWithUserShell = async (command, options) => {
8892
8922
  signal: "SIGTERM"
8893
8923
  }
8894
8924
  );
8895
- try {
8896
- child.kill("SIGTERM");
8897
- } catch {
8898
- }
8925
+ terminate("SIGTERM");
8899
8926
  finish(() => reject(error));
8900
8927
  return;
8901
8928
  }
@@ -8942,15 +8969,22 @@ var runShellWithUserShell = async (command, options) => {
8942
8969
  });
8943
8970
  timeoutHandle = setTimeout(() => {
8944
8971
  timedOut = true;
8945
- try {
8946
- child.kill("SIGTERM");
8947
- } catch {
8948
- }
8949
- setTimeout(() => {
8950
- try {
8951
- if (!child.killed) child.kill("SIGKILL");
8952
- } catch {
8972
+ const timeoutError = Object.assign(
8973
+ new Error(
8974
+ `Command timed out after ${Math.trunc(options.timeoutMs / 1e3)}s`
8975
+ ),
8976
+ {
8977
+ code: "ETIMEDOUT",
8978
+ stdout,
8979
+ stderr,
8980
+ killed: true,
8981
+ signal: "SIGTERM"
8953
8982
  }
8983
+ );
8984
+ terminate("SIGTERM");
8985
+ finish(() => reject(timeoutError));
8986
+ setTimeout(() => {
8987
+ terminate("SIGKILL");
8954
8988
  }, 2e3).unref();
8955
8989
  }, options.timeoutMs);
8956
8990
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codelia/runtime",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=20 <25"
@@ -23,14 +23,14 @@
23
23
  "typecheck": "tsc --noEmit"
24
24
  },
25
25
  "dependencies": {
26
- "@codelia/config": "0.1.30",
27
- "@codelia/config-loader": "0.1.30",
28
- "@codelia/core": "0.1.30",
29
- "@codelia/logger": "0.1.30",
30
- "@codelia/model-metadata": "0.1.30",
31
- "@codelia/protocol": "0.1.30",
32
- "@codelia/shared-types": "0.1.30",
33
- "@codelia/storage": "0.1.30",
26
+ "@codelia/config": "0.1.32",
27
+ "@codelia/config-loader": "0.1.32",
28
+ "@codelia/core": "0.1.32",
29
+ "@codelia/logger": "0.1.32",
30
+ "@codelia/model-metadata": "0.1.32",
31
+ "@codelia/protocol": "0.1.32",
32
+ "@codelia/shared-types": "0.1.32",
33
+ "@codelia/storage": "0.1.32",
34
34
  "eventsource-parser": "^3.0.6",
35
35
  "oauth4webapi": "^3.8.4",
36
36
  "zod": "^4.3.5"