@rip-lang/swarm 1.2.7 → 1.2.8
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/package.json +1 -1
- package/swarm.rip +12 -16
package/package.json
CHANGED
package/swarm.rip
CHANGED
|
@@ -214,21 +214,6 @@ export swarm = (opts = {}) ->
|
|
|
214
214
|
catch
|
|
215
215
|
null
|
|
216
216
|
|
|
217
|
-
# pre-flight: check workers can resolve modules from script directory
|
|
218
|
-
dir = dirname(scriptPath)
|
|
219
|
-
found = false
|
|
220
|
-
loop
|
|
221
|
-
if existsSync(join(dir, 'node_modules', '@rip-lang', 'swarm'))
|
|
222
|
-
found = true
|
|
223
|
-
break
|
|
224
|
-
parent = dirname(dir)
|
|
225
|
-
break if parent is dir
|
|
226
|
-
dir = parent
|
|
227
|
-
unless found
|
|
228
|
-
console.error "swarm: no node_modules found — workers won't be able to load modules"
|
|
229
|
-
console.error "hint: run 'bun add @rip-lang/all' in your project directory"
|
|
230
|
-
exit 1
|
|
231
|
-
|
|
232
217
|
# state
|
|
233
218
|
live = 0
|
|
234
219
|
done = 0
|
|
@@ -293,12 +278,14 @@ export swarm = (opts = {}) ->
|
|
|
293
278
|
w.on 'message', (msg) ->
|
|
294
279
|
switch msg.type
|
|
295
280
|
when 'error'
|
|
281
|
+
writeFileSync('.swarm/errors.log', "worker #{slot} startup: #{msg.error}\n", { flag: 'a' }) if existsSync(_dir)
|
|
296
282
|
unless fatal
|
|
297
283
|
fatal = true
|
|
298
284
|
cursor(true) unless quiet
|
|
285
|
+
write go(workers + 5, 1) unless quiet
|
|
299
286
|
console.error "\nswarm: #{msg.error}"
|
|
300
287
|
console.error "hint: run 'bun add @rip-lang/all' in your project directory" if msg.error.includes('Cannot find module')
|
|
301
|
-
|
|
288
|
+
exit 1
|
|
302
289
|
when 'ready'
|
|
303
290
|
dispatchNext(w, slot)
|
|
304
291
|
when 'done'
|
|
@@ -326,6 +313,15 @@ export swarm = (opts = {}) ->
|
|
|
326
313
|
|
|
327
314
|
w.on 'exit', (code) ->
|
|
328
315
|
writeFileSync('.swarm/errors.log', "worker #{slot} exited with code #{code}, inflight: #{inflight[slot]}\n", { flag: 'a' }) if existsSync(_dir)
|
|
316
|
+
# startup failure — worker never became ready
|
|
317
|
+
if code isnt 0 and not info[slot]? and not fatal
|
|
318
|
+
fatal = true
|
|
319
|
+
cursor(true) unless quiet
|
|
320
|
+
write go(workers + 5, 1) unless quiet
|
|
321
|
+
console.error "\nswarm: worker #{slot} failed to start (exit code #{code})"
|
|
322
|
+
console.error "hint: run 'bun add @rip-lang/all' in your project directory"
|
|
323
|
+
console.error " check .swarm/errors.log for details"
|
|
324
|
+
exit 1
|
|
329
325
|
# if worker crashed mid-task, count the in-flight task as died
|
|
330
326
|
if inflight[slot]
|
|
331
327
|
move(inflight[slot], _died)
|