engine/process_guards

Process-level guards for the Gingee master and isolation workers. Engine-internal — not for sandboxed app require. - **unhandledRejection:** log and keep listening. Detached async throws are not part of the handler promise awaited by script_runner; without a listener Node's default (--unhandled-rejections=throw) would exit the whole multi-app process. - **uncaughtException:** log (state may be corrupt), run optional graceful shutdown, then process.exit(1). Do not keep running quietly after a sync uncaught exception.
Description:
  • Process-level guards for the Gingee master and isolation workers. Engine-internal — not for sandboxed app require. - **unhandledRejection:** log and keep listening. Detached async throws are not part of the handler promise awaited by script_runner; without a listener Node's default (--unhandled-rejections=throw) would exit the whole multi-app process. - **uncaughtException:** log (state may be corrupt), run optional graceful shutdown, then process.exit(1). Do not keep running quietly after a sync uncaught exception.

Members

(inner) activeLogger :object|null

Type:
  • object | null

(inner) fatalInProgress :boolean

Type:
  • boolean

(inner) onFatalShutdown :function|null

Type:
  • function | null

(inner) rejectionHandler :function|null

Type:
  • function | null

(inner) rejectionRegistered :boolean

Type:
  • boolean

(inner) uncaughtHandler :function|null

Type:
  • function | null

(inner) uncaughtRegistered :boolean

Type:
  • boolean

Methods

(inner) bindGuardOptions(loggeropt, optionsopt)

Description:
  • Bind logger / fatal shutdown callback (safe to call on every boot).
Parameters:
Name Type Attributes Description
logger object <optional>
options object <optional>
Properties
Name Type Attributes Description
onFatalShutdown function <optional>
Sync cleanup before exit (master shutdown).

(inner) formatReason(reason) → {Object}

Description:
  • Format a rejection / exception value for logging.
Parameters:
Name Type Description
reason *
Returns:
Type
Object

(inner) onUncaughtException(err)

Description:
  • Sync uncaught exception: log, optional graceful shutdown, then exit. Re-entry safe (second throw during shutdown still forces exit).
Parameters:
Name Type Description
err Error

(inner) onUnhandledRejection(reason, promiseopt)

Parameters:
Name Type Attributes Description
reason *
promise Promise <optional>

(inner) registerProcessGuards(logger, optionsopt)

Description:
  • Register both process guards (idempotent). Preferred single entry for boot / workers.
Parameters:
Name Type Attributes Description
logger object
options object <optional>
Properties
Name Type Attributes Description
onFatalShutdown function <optional>
Called on uncaughtException before exit(1).

(inner) registerUncaughtExceptionGuard(logger, optionsopt)

Description:
  • Register idempotent process.on('uncaughtException') listener. Logs, runs options.onFatalShutdown if set, then process.exit(1).
Parameters:
Name Type Attributes Description
logger object
options object <optional>
Properties
Name Type Attributes Description
onFatalShutdown function <optional>

(inner) registerUnhandledRejectionGuard(logger, optionsopt)

Description:
  • Register idempotent process.on('unhandledRejection') listener.
Parameters:
Name Type Attributes Description
logger object
options object <optional>