Skip to content

Commit

Permalink
endError event takes a BatchProcess now (for more detailed logging)
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen committed Mar 1, 2022
1 parent f9128c3 commit 80a329e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/BatchCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,6 @@ export class BatchCluster {
process.removeListener("exit", this.#exitListener)
this.#endPromise = new Deferred<void>().observe(
this.closeChildProcesses(gracefully)
.catch((err) => {
this.emitter.emit("endError", err)
})
.then(() => {
this.emitter.emit("end")
})
Expand Down Expand Up @@ -361,7 +358,7 @@ export class BatchCluster {
procs.map((proc) =>
proc
.end(gracefully, "ending")
.catch((err) => this.emitter.emit("endError", asError(err)))
.catch((err) => this.emitter.emit("endError", asError(err), proc))
)
)
}
Expand Down
12 changes: 6 additions & 6 deletions src/BatchClusterEmitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ export interface BatchClusterEvents {
*
* @param childProcess will be undefined if the error is from {@link ChildProcessFactory.processFactory}
*/
startError: (err: Error, childProcess?: BatchProcess) => void
startError: (error: Error, childProcess?: BatchProcess) => void

/**
* Emitted when an internal consistency check fails
*/
internalError: (err: Error) => void
internalError: (error: Error) => void

/**
* Emitted when `.end()` is called because the error rate has exceeded
* {@link BatchClusterOptions.maxReasonableProcessFailuresPerMinute}
*/
fatalError: (err: Error) => void
fatalError: (error: Error) => void

/**
* Emitted when tasks receive data, which may be partial chunks from the task
Expand All @@ -87,7 +87,7 @@ export interface BatchClusterEvents {
/**
* Emitted when a task has an error
*/
taskError: (err: Error, task: Task, proc: BatchProcess) => void
taskError: (error: Error, task: Task, proc: BatchProcess) => void

/**
* Emitted when child processes write to stdout or stderr without a current
Expand All @@ -102,12 +102,12 @@ export interface BatchClusterEvents {
/**
* Emitted when a process fails health checks
*/
healthCheckError: (err: Error, proc: BatchProcess) => void
healthCheckError: (error: Error, proc: BatchProcess) => void

/**
* Emitted when a child process has an error during shutdown
*/
endError: (err: Error) => void
endError: (error: Error, proc?: BatchProcess) => void

/**
* Emitted when this instance is in the process of ending.
Expand Down

0 comments on commit 80a329e

Please sign in to comment.