slopcode 0.2.148 → 0.2.149

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.
Binary file
Binary file
package/bin/slopcode CHANGED
@@ -19,17 +19,29 @@ function startupLog(phase, extra = {}) {
19
19
  }
20
20
 
21
21
  function run(target, options = {}) {
22
- startupLog("launcher.exec", { target: path.basename(target) })
23
- const result = childProcess.spawnSync(target, options.args || process.argv.slice(2), {
24
- stdio: "inherit",
25
- env: options.env ? { ...process.env, ...options.env } : process.env,
26
- })
27
- if (result.error) {
28
- console.error(result.error.message)
29
- process.exit(1)
22
+ const maxRetries = 3
23
+ for (let attempt = 0; attempt <= maxRetries; attempt++) {
24
+ startupLog("launcher.exec", { target: path.basename(target), attempt })
25
+ const result = childProcess.spawnSync(target, options.args || process.argv.slice(2), {
26
+ stdio: "inherit",
27
+ env: options.env ? { ...process.env, ...options.env } : process.env,
28
+ })
29
+ if (result.error) {
30
+ console.error(result.error.message)
31
+ process.exit(1)
32
+ }
33
+ if (result.signal === "SIGABRT" && attempt < maxRetries) {
34
+ console.error(`slopcode crashed (SIGABRT), retrying (${attempt + 1}/${maxRetries})...`)
35
+ continue
36
+ }
37
+ if (result.signal) {
38
+ try {
39
+ process.kill(process.pid, result.signal)
40
+ } catch {}
41
+ }
42
+ const code = typeof result.status === "number" ? result.status : 1
43
+ process.exit(code)
30
44
  }
31
- const code = typeof result.status === "number" ? result.status : 0
32
- process.exit(code)
33
45
  }
34
46
 
35
47
  const envPath = process.env.SLOPCODE_BIN_PATH