@o3co/create-auth-policy-verifier 0.8.0 → 0.8.1
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/package.json
CHANGED
|
@@ -239,6 +239,34 @@ describe("installGracefulShutdown", () => {
|
|
|
239
239
|
expect(exitProcess).toHaveBeenCalledWith(3);
|
|
240
240
|
});
|
|
241
241
|
|
|
242
|
+
it("reports the cleanup outcome as the reason, not the drain that preceded it", async () => {
|
|
243
|
+
// `exitCode` became 1 while `reason` still said "drained", so the one line
|
|
244
|
+
// an operator alerts on contradicted itself. The drain outcome is still
|
|
245
|
+
// carried, under its own key, so neither fact is lost.
|
|
246
|
+
const { signals, finishDraining, logger, exit } = install({
|
|
247
|
+
cleanup: () => Promise.reject(new Error("teardown failed")),
|
|
248
|
+
});
|
|
249
|
+
signals.get("SIGTERM")?.();
|
|
250
|
+
finishDraining();
|
|
251
|
+
await settle();
|
|
252
|
+
expect(logger.info).toHaveBeenCalledWith(
|
|
253
|
+
{ reason: "cleanup-failed", drain: "drained", exitCode: 1 },
|
|
254
|
+
"graceful shutdown: complete",
|
|
255
|
+
);
|
|
256
|
+
expect(exit).toHaveBeenCalledWith(1);
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it("keeps reason and drain identical when cleanup succeeds", async () => {
|
|
260
|
+
const { signals, finishDraining, logger } = install({ cleanup: () => Promise.resolve() });
|
|
261
|
+
signals.get("SIGTERM")?.();
|
|
262
|
+
finishDraining();
|
|
263
|
+
await settle();
|
|
264
|
+
expect(logger.info).toHaveBeenCalledWith(
|
|
265
|
+
{ reason: "drained", drain: "drained", exitCode: 0 },
|
|
266
|
+
"graceful shutdown: complete",
|
|
267
|
+
);
|
|
268
|
+
});
|
|
269
|
+
|
|
242
270
|
it("removes its own signal listeners once shutting down", () => {
|
|
243
271
|
const { signals } = install();
|
|
244
272
|
signals.get("SIGTERM")?.();
|
|
@@ -61,7 +61,7 @@ export interface GracefulShutdownOptions {
|
|
|
61
61
|
* sequence — size both against the orchestrator's grace period, not one.
|
|
62
62
|
*/
|
|
63
63
|
readonly cleanupTimeoutMs?: number;
|
|
64
|
-
/** Injected in tests; defaults to
|
|
64
|
+
/** Injected in tests; defaults to {@link deferExit}. */
|
|
65
65
|
readonly exit?: (code: number) => void;
|
|
66
66
|
/** Injected in tests; defaults to `process.on`. */
|
|
67
67
|
readonly onSignal?: (signal: NodeJS.Signals, handler: () => void) => void;
|
|
@@ -136,10 +136,16 @@ export function installGracefulShutdown(server: Server, options: GracefulShutdow
|
|
|
136
136
|
if (finished) return;
|
|
137
137
|
finished = true;
|
|
138
138
|
let exitCode = code;
|
|
139
|
+
// `reason` names whatever decided the exit code, so the line an operator
|
|
140
|
+
// alerts on cannot say "drained" next to a non-zero code. The drain
|
|
141
|
+
// outcome keeps its own key rather than being overwritten — both facts
|
|
142
|
+
// are wanted, and a stable shape is what makes the line queryable.
|
|
143
|
+
let outcome = reason;
|
|
139
144
|
try {
|
|
140
145
|
if ((await runCleanup()) === CLEANUP_TIMED_OUT) {
|
|
141
146
|
logger.error({ cleanupTimeoutMs }, "graceful shutdown: cleanup timed out");
|
|
142
147
|
exitCode = 1;
|
|
148
|
+
outcome = "cleanup-timeout";
|
|
143
149
|
}
|
|
144
150
|
} catch (err) {
|
|
145
151
|
// Through the app logger, not `console.error`: a shutdown that
|
|
@@ -148,8 +154,9 @@ export function installGracefulShutdown(server: Server, options: GracefulShutdow
|
|
|
148
154
|
// drops.
|
|
149
155
|
logger.error({ err }, "graceful shutdown: cleanup failed");
|
|
150
156
|
exitCode = 1;
|
|
157
|
+
outcome = "cleanup-failed";
|
|
151
158
|
}
|
|
152
|
-
logger.info({ reason, exitCode }, "graceful shutdown: complete");
|
|
159
|
+
logger.info({ reason: outcome, drain: reason, exitCode }, "graceful shutdown: complete");
|
|
153
160
|
exit(exitCode);
|
|
154
161
|
};
|
|
155
162
|
|
package/templates/versions.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"@o3co/auth.policy-verifier.core": "0.8.
|
|
3
|
-
"@o3co/auth.policy-verifier.builtins": "0.8.
|
|
4
|
-
"@o3co/auth.policy-verifier.server": "0.8.
|
|
2
|
+
"@o3co/auth.policy-verifier.core": "0.8.1",
|
|
3
|
+
"@o3co/auth.policy-verifier.builtins": "0.8.1",
|
|
4
|
+
"@o3co/auth.policy-verifier.server": "0.8.1"
|
|
5
5
|
}
|