summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
251d6ac)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
+### Fixed
+
+- Ensure no task can be executed when the pool is destroyed.
+
### Added
- Add `queueMaxSize` option to tasks queue options.
### Added
- Add `queueMaxSize` option to tasks queue options.
* Whether the pool is starting or not.
*/
private readonly starting: boolean
* Whether the pool is starting or not.
*/
private readonly starting: boolean
+ /**
+ * Whether the pool is started or not.
+ */
+ private started: boolean
/**
* The start timestamp of the pool.
*/
/**
* The start timestamp of the pool.
*/
this.starting = true
this.startPool()
this.starting = false
this.starting = true
this.startPool()
this.starting = false
this.startTimestamp = performance.now()
}
this.startTimestamp = performance.now()
}
transferList?: TransferListItem[]
): Promise<Response> {
return await new Promise<Response>((resolve, reject) => {
transferList?: TransferListItem[]
): Promise<Response> {
return await new Promise<Response>((resolve, reject) => {
+ if (!this.started) {
+ reject(new Error('Cannot execute a task on destroyed pool'))
+ }
if (name != null && typeof name !== 'string') {
reject(new TypeError('name argument must be a string'))
}
if (name != null && typeof name !== 'string') {
reject(new TypeError('name argument must be a string'))
}
})
)
this.emitter?.emit(PoolEvents.destroy, this.info)
})
)
this.emitter?.emit(PoolEvents.destroy, this.info)
}
protected async sendKillMessageToWorker (
}
protected async sendKillMessageToWorker (
workerInfo.ready = false
this.workerNodes[workerNodeKey].closeChannel()
this.emitter?.emit(PoolEvents.error, error)
workerInfo.ready = false
this.workerNodes[workerNodeKey].closeChannel()
this.emitter?.emit(PoolEvents.error, error)
- if (this.opts.restartWorkerOnError === true && !this.starting) {
+ if (
+ this.opts.restartWorkerOnError === true &&
+ !this.starting &&
+ this.started
+ ) {
if (workerInfo.dynamic) {
this.createAndSetupDynamicWorkerNode()
} else {
if (workerInfo.dynamic) {
this.createAndSetupDynamicWorkerNode()
} else {