Skip to content

Commit 2fad0f3

Browse files
authored
Merge pull request #269 from module-federation/release-0-1-0
prevent thread count from rising above max
2 parents bee4c7d + 278935b commit 2fad0f3

File tree

2 files changed

+58
-3
lines changed

2 files changed

+58
-3
lines changed

nohup.out

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3211,3 +3211,53 @@ Error: Command failed: ./watch.sh 80 8888
32113211
signal: null,
32123212
cmd: './watch.sh 80 8888'
32133213
}
3214+
change domain/thread-pool.js
3215+
Error: Command failed: ./watch.sh 80 8888
3216+
3217+
at ChildProcess.exithandler (node:child_process:402:12)
3218+
at ChildProcess.emit (node:events:513:28)
3219+
at maybeClose (node:internal/child_process:1100:16)
3220+
at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5) {
3221+
code: 7,
3222+
killed: false,
3223+
signal: null,
3224+
cmd: './watch.sh 80 8888'
3225+
}
3226+
change domain/thread-pool.js
3227+
Error: Command failed: ./watch.sh 80 8888
3228+
3229+
at ChildProcess.exithandler (node:child_process:402:12)
3230+
at ChildProcess.emit (node:events:513:28)
3231+
at maybeClose (node:internal/child_process:1100:16)
3232+
at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5) {
3233+
code: 7,
3234+
killed: false,
3235+
signal: null,
3236+
cmd: './watch.sh 80 8888'
3237+
}
3238+
change domain/thread-pool.js
3239+
Error: Command failed: ./watch.sh 80 8888
3240+
3241+
at ChildProcess.exithandler (node:child_process:402:12)
3242+
at ChildProcess.emit (node:events:513:28)
3243+
at maybeClose (node:internal/child_process:1100:16)
3244+
at Socket.<anonymous> (node:internal/child_process:458:11)
3245+
at Socket.emit (node:events:513:28)
3246+
at Pipe.<anonymous> (node:net:301:12) {
3247+
code: 7,
3248+
killed: false,
3249+
signal: null,
3250+
cmd: './watch.sh 80 8888'
3251+
}
3252+
change domain/thread-pool.js
3253+
Error: Command failed: ./watch.sh 80 8888
3254+
3255+
at ChildProcess.exithandler (node:child_process:402:12)
3256+
at ChildProcess.emit (node:events:513:28)
3257+
at maybeClose (node:internal/child_process:1100:16)
3258+
at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5) {
3259+
code: 7,
3260+
killed: false,
3261+
signal: null,
3262+
cmd: './watch.sh 80 8888'
3263+
}

src/domain/thread-pool.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export class ThreadPool extends EventEmitter {
164164

165165
if (options?.preload) {
166166
console.info('preload enabled for', this.name)
167-
this.startThreads(true)
167+
this.startThreads()
168168
}
169169
}
170170

@@ -516,6 +516,7 @@ export class ThreadPool extends EventEmitter {
516516
errorTolerance: this.errorRateThreshold(),
517517
errors: this.errorCount(),
518518
deployments: this.deploymentCount(),
519+
poolCanGrow: this.poolCanGrow(),
519520
...Object.entries(process.memoryUsage())
520521
.map(([k, v]) => ({ [`${k}Mb`]: Math.round(v / 1024 / 1024) }))
521522
.reduce((a, b) => ({ ...a, ...b })),
@@ -593,6 +594,10 @@ export class ThreadPool extends EventEmitter {
593594
return this
594595
}
595596

597+
enqueue (job) {
598+
this.waitingJobs.push(thread => thread.run(job))
599+
}
600+
596601
/**
597602
* Run a job (use case function) on an available thread; or queue the job
598603
* until one becomes available.
@@ -620,15 +625,15 @@ export class ThreadPool extends EventEmitter {
620625
...options
621626
})
622627

623-
let thread = this.checkout()
628+
const thread = this.checkout()
624629

625630
if (thread) {
626631
thread.run(job)
627632
return
628633
}
629634

630635
console.warn('no threads: queuing job', jobName)
631-
this.waitingJobs.push(thread => thread.run(job))
636+
this.enqueue(job)
632637
this.incrementJobsQueued()
633638
})
634639
}

0 commit comments

Comments
 (0)