lifecycleion 0.0.3 → 0.0.4

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Lifecycleion v0.0.3
1
+ # Lifecycleion v0.0.4
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/lifecycleion.svg)](https://badge.fury.io/js/lifecycleion)
4
4
 
@@ -1986,6 +1986,8 @@ var LifecycleManager = class extends EventEmitterProtected {
1986
1986
  isShuttingDown = false;
1987
1987
  // Unique token used to detect shutdowns that happened during async start().
1988
1988
  shutdownToken = (0, import_ulid2.ulid)();
1989
+ // Resolver for the first logger.exit() deferred during an already-running shutdown.
1990
+ pendingLoggerExitResolve = null;
1989
1991
  shutdownMethod = null;
1990
1992
  lastShutdownResult = null;
1991
1993
  // Signal management
@@ -3045,6 +3047,17 @@ var LifecycleManager = class extends EventEmitterProtected {
3045
3047
  this.rootLogger.setBeforeExitCallback(
3046
3048
  async (exitCode, isFirstExit) => {
3047
3049
  if (this.isShuttingDown) {
3050
+ if (isFirstExit && this.pendingLoggerExitResolve === null) {
3051
+ this.logger.debug(
3052
+ "Logger exit called during shutdown, waiting...",
3053
+ {
3054
+ params: { exitCode }
3055
+ }
3056
+ );
3057
+ return await new Promise((resolve) => {
3058
+ this.pendingLoggerExitResolve = resolve;
3059
+ });
3060
+ }
3048
3061
  this.logger.debug("Logger exit called during shutdown, waiting...", {
3049
3062
  params: { exitCode }
3050
3063
  });
@@ -4150,7 +4163,19 @@ var LifecycleManager = class extends EventEmitterProtected {
4150
4163
  }
4151
4164
  this.isShuttingDown = false;
4152
4165
  this.updateStartedFlag();
4166
+ this.finalizePendingLoggerExit();
4167
+ }
4168
+ }
4169
+ /**
4170
+ * Release a deferred logger.exit() request after shutdown fully settles.
4171
+ */
4172
+ finalizePendingLoggerExit() {
4173
+ if (this.pendingLoggerExitResolve === null || this.isShuttingDown) {
4174
+ return;
4153
4175
  }
4176
+ const resolve = this.pendingLoggerExitResolve;
4177
+ this.pendingLoggerExitResolve = null;
4178
+ resolve({ action: "proceed" });
4154
4179
  }
4155
4180
  /**
4156
4181
  * Retry shutdown for a stalled component.