@idlebox/node 1.4.28 → 1.4.29

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.
@@ -0,0 +1,202 @@
1
+ /** biome-ignore-all lint/suspicious/noDebugger: debug file */
2
+
3
+ import { ensureGlobalObject, getRootCause, isProductionMode, objectName, prettyPrintError } from '@idlebox/common';
4
+ import { ErrorWithCode, Exit, ExitCode, InterruptError, ProxiedError, UncaughtException, UnhandledRejection } from '@idlebox/errors';
5
+ import { syncBuiltinESMExports } from 'node:module';
6
+ import { basename } from 'node:path';
7
+ import process from 'node:process';
8
+ import { inspect } from 'node:util';
9
+ import { getHandlerOnError } from './custom-error-handlers.js';
10
+ import { _shutdown_graceful, isShuttingDown, setExitCodeIfNot, shutdown, shutdown_immediate, shuttingDownCounter } from './process-shutdown.js';
11
+
12
+ const prefix = process.stderr.isTTY ? '' : `<${title()} ${process.pid}> `;
13
+ let logger!: IDebugOutput;
14
+
15
+ function title() {
16
+ if (process.title && process.title !== 'node') {
17
+ return process.title;
18
+ }
19
+ return basename(process.argv[1] || '') || 'node';
20
+ }
21
+
22
+ function hasCode(e: unknown): e is ErrorWithCode {
23
+ return typeof e === 'object' && e !== null && 'code' in e;
24
+ }
25
+
26
+ /**
27
+ * 全局最终错误处理器
28
+ * 所有未捕获的异常、没有处理的rejection等等都会经过这里
29
+ */
30
+ function uniqueErrorHandler(caughtError: unknown) {
31
+ const effectiveError: unknown = caughtError instanceof ProxiedError ? caughtError.cause : caughtError;
32
+ const exitCode = hasCode(effectiveError) ? effectiveError.code : ExitCode.PROGRAM;
33
+ setExitCodeIfNot(exitCode);
34
+
35
+ if (!isProductionMode) logger.verbose?.(`uniqueErrorHandler:`);
36
+ if (effectiveError instanceof Error === false) {
37
+ // 如果抛出的是非Error对象,即使是NotError
38
+ // 不可能处理,立即退出程序
39
+ let e: any;
40
+ if (effectiveError && typeof effectiveError === 'object' && (effectiveError as any).message) {
41
+ e = effectiveError;
42
+ } else {
43
+ e = new Error(`error object is ${typeof effectiveError} ${effectiveError ? (effectiveError as any).constructor?.name : 'unknown'}`);
44
+ }
45
+ prettyPrintError(`${prefix}全局异常处理器捕获到非预期对象`, e);
46
+ throw shutdown_immediate(exitCode);
47
+ }
48
+
49
+ if (effectiveError instanceof Exit) {
50
+ /**
51
+ * Exit或者继承自Exit的错误被抛出
52
+ * 说明是预期中的退出流程,直接退出,不进行任何处理
53
+ */
54
+ if (!isProductionMode) logger.verbose?.(` - skip exit object`);
55
+ if (!isShuttingDown()) _shutdown_graceful(effectiveError.code);
56
+ throw effectiveError;
57
+ }
58
+
59
+ try {
60
+ const catcher = getHandlerOnError(effectiveError);
61
+ if (catcher) {
62
+ if (!isProductionMode) logger.verbose?.(` - call catcher ${objectName(catcher)}`);
63
+ catcher(effectiveError);
64
+ return;
65
+ }
66
+ } catch (ee: any) {
67
+ if (ee instanceof Exit) return;
68
+ prettyPrintError(`${prefix}error while handle error`, {
69
+ message: ee.message,
70
+ stack: ee.stack,
71
+ cause: effectiveError,
72
+ });
73
+ logger.output(`${prefix}died.`);
74
+ shutdown_immediate(ExitCode.PROGRAM);
75
+ }
76
+
77
+ if (effectiveError instanceof InterruptError) {
78
+ if (!isProductionMode) logger.verbose?.(` - shuttingDown = ${shuttingDownCounter}`);
79
+
80
+ const signal = effectiveError.signal;
81
+ if (signal === 'SIGINT') {
82
+ process.stderr.write(shuttingDownCounter === 0 ? '\n' : '\r');
83
+ }
84
+ if (shuttingDownCounter > 4) {
85
+ logger.output(`${prefix}Received ${signal} more than 5 times. Exiting immediately.`);
86
+ shutdown_immediate(ExitCode.INTERRUPT);
87
+ } else if (shuttingDownCounter > 0) {
88
+ logger.output(`${prefix}Received ${signal} ${shuttingDownCounter + 1} times.`);
89
+ } else {
90
+ logger.output(`${prefix}Received ${signal}. Exiting gracefully...`);
91
+ }
92
+ shutdown(ExitCode.INTERRUPT);
93
+ }
94
+
95
+ const rootCause = getRootCause(effectiveError);
96
+ if (effectiveError instanceof UnhandledRejection) {
97
+ if (!isProductionMode) logger.verbose?.(` - UnhandledRejection`);
98
+ if (rootCause !== effectiveError) {
99
+ prettyPrintError(`${prefix}Unhandled Rejection`, effectiveError.cause);
100
+ } else {
101
+ logger.output(`${prefix}Unhandled Rejection / error type unknown: ${inspect(effectiveError.cause)}`);
102
+ }
103
+ return;
104
+ }
105
+ if (effectiveError instanceof UncaughtException) {
106
+ if (!isProductionMode) logger.verbose?.(` - UncaughtException`);
107
+ if (rootCause !== effectiveError) {
108
+ prettyPrintError(`${prefix}Unhandled Exception`, effectiveError.cause);
109
+ } else {
110
+ logger.output(`${prefix}Unhandled Exception / error type unknown: ${inspect(effectiveError.cause)}`);
111
+ }
112
+ return;
113
+ }
114
+
115
+ if (!isProductionMode) logger.verbose?.(` - common error`);
116
+ prettyPrintError(`${prefix}unhandled global exception`, effectiveError);
117
+ shutdown(ExitCode.PROGRAM);
118
+ }
119
+
120
+ interface IDebugOutput {
121
+ output(message: string): void;
122
+ verbose?(message: string): void;
123
+ }
124
+
125
+ /**
126
+ * 注册nodejs退出处理器
127
+ */
128
+ export function registerNodejsExitHandler(_logger: IDebugOutput = { output: console.error }) {
129
+ logger = _logger;
130
+ ensureGlobalObject('exithandler/register', () => _real_register());
131
+ }
132
+
133
+ function _real_register() {
134
+ if (!isProductionMode) logger.verbose?.(`register nodejs exit handler: production=${isProductionMode}`);
135
+
136
+ process.on('SIGINT', () => signal_handler('SIGINT'));
137
+ process.on('SIGTERM', () => signal_handler('SIGTERM'));
138
+
139
+ function signal_handler(signal: 'SIGINT' | 'SIGTERM') {
140
+ setImmediate(() => {
141
+ uniqueErrorHandler(new InterruptError(signal, { boundary: signal_handler }));
142
+ });
143
+ }
144
+
145
+ process.on('beforeExit', (code) => {
146
+ if (!isProductionMode) logger.verbose?.(`process: beforeExit: ${code}`);
147
+ if (process.exitCode === undefined || process.exitCode === '') {
148
+ code = ExitCode.EXECUTION;
149
+ logger.output(`${prefix}beforeExit called, but process.exitCode has not been set, switch to ${code}`);
150
+ }
151
+ _shutdown_graceful(code);
152
+ });
153
+
154
+ if (process.hasUncaughtExceptionCaptureCallback()) {
155
+ process.on('uncaughtException', uncaughtExceptionHandle);
156
+ throw new Error(`${prefix} [uncaught exception capture] callback already registered by other module`);
157
+ }
158
+ process.setUncaughtExceptionCaptureCallback(uncaughtExceptionHandle);
159
+
160
+ process.on('unhandledRejection', (reason, promise) => {
161
+ callHandler(new UnhandledRejection(reason, promise));
162
+ });
163
+
164
+ process.exit = shutdown;
165
+ syncBuiltinESMExports();
166
+
167
+ return true;
168
+
169
+ function uncaughtExceptionHandle(error: Error): void {
170
+ callHandler(new UncaughtException(error));
171
+ }
172
+
173
+ function callHandler(e: UnhandledRejection | UncaughtException) {
174
+ if (!isProductionMode) logger.verbose?.(`callHandler: ${objectName(e)}`);
175
+ try {
176
+ uniqueErrorHandler(e);
177
+
178
+ if (e.cause instanceof ErrorWithCode) {
179
+ if (!isProductionMode) logger.verbose?.(`finalThrow: got code: ${e.cause.code}`);
180
+ _shutdown_graceful(e.cause.code);
181
+ } else {
182
+ if (!isProductionMode) logger.verbose?.(`finalThrow: not got code: ${e.cause} `);
183
+ _shutdown_graceful(ExitCode.PROGRAM);
184
+ }
185
+ } catch (ee: any) {
186
+ if (ee instanceof Exit) {
187
+ return;
188
+ }
189
+ prettyPrintError('Exception while handling error', ee);
190
+ shutdown_immediate(ExitCode.PROGRAM);
191
+ }
192
+ }
193
+ }
194
+
195
+ /**
196
+ * @deprecated 仅用于测试
197
+ */
198
+ export function die(message: string): never {
199
+ debugger;
200
+ console.error(`${prefix}DIE!`, message);
201
+ shutdown_immediate(1);
202
+ }
@@ -1,22 +0,0 @@
1
- /** biome-ignore-all lint/suspicious/noDebugger: debug file */
2
- import { type MyCallback } from '@idlebox/common';
3
- export declare function setExitCodeIfNot(exitCode: number): void;
4
- export declare function shutdown(exitCode: number): never;
5
- export declare function isShuttingDown(): boolean;
6
- type ErrorConstructor = new (...args: any[]) => Error;
7
- export declare function registerNodejsGlobalTypedErrorHandlerWithInheritance(ErrorCls: ErrorConstructor, fn: MyCallback<[Error]>): void;
8
- export declare function registerNodejsGlobalTypedErrorHandler(ErrorCls: ErrorConstructor, fn: MyCallback<[Error]>): void;
9
- interface IDebugOutput {
10
- output(message: string): void;
11
- verbose?(message: string): void;
12
- }
13
- /**
14
- * 注册nodejs退出处理器
15
- */
16
- export declare function registerNodejsExitHandler(logger?: IDebugOutput): void;
17
- /**
18
- * @deprecated 仅用于测试
19
- */
20
- export declare function die(message: string): never;
21
- export {};
22
- //# sourceMappingURL=register.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/lifecycle/register.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EAA6F,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAsB7I,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,QAKhD;AAGD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,KAAK,CAGhD;AACD,wBAAgB,cAAc,YAE7B;AAiBD,KAAK,gBAAgB,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC;AAEtD,wBAAgB,oDAAoD,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,QAMvH;AACD,wBAAgB,qCAAqC,CAAC,QAAQ,EAAE,gBAAgB,EAAE,EAAE,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,QAMxG;AA2FD,UAAU,YAAY;IACrB,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,GAAE,YAAwC,QAEzF;AA+DD;;GAEG;AACH,wBAAgB,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAI1C"}
@@ -1,226 +0,0 @@
1
- /** biome-ignore-all lint/suspicious/noDebugger: debug file */
2
- import { ensureDisposeGlobal, ensureGlobalObject, functionName, isProductionMode, prettyPrintError } from '@idlebox/common';
3
- import { ErrorWithCode, Exit, ExitCode, InterruptError, UncaughtException, UnhandledRejection } from '@idlebox/errors';
4
- import assert from 'node:assert';
5
- import { syncBuiltinESMExports } from 'node:module';
6
- import { basename } from 'node:path';
7
- import process from 'node:process';
8
- import { inspect } from 'node:util';
9
- const shutdown_immediate = process.exit;
10
- const prefix = process.stderr.isTTY ? '' : `<${title()} ${process.pid}> `;
11
- function title() {
12
- if (process.title && process.title !== 'node') {
13
- return process.title;
14
- }
15
- return basename(process.argv[1] || '') || 'node';
16
- }
17
- function getCurrentCode() {
18
- return typeof process.exitCode === 'string' ? parseInt(process.exitCode, 10) : process.exitCode || 0;
19
- }
20
- export function setExitCodeIfNot(exitCode) {
21
- if (exitCode || typeof process.exitCode !== 'number') {
22
- process.exitCode = exitCode;
23
- globalThis.process.exitCode = exitCode;
24
- }
25
- }
26
- let shuttingDown = 0;
27
- export function shutdown(exitCode) {
28
- _shutdown_graceful(exitCode);
29
- throw new Exit(getCurrentCode());
30
- }
31
- export function isShuttingDown() {
32
- return shuttingDown > 0;
33
- }
34
- function _shutdown_graceful(exitCode) {
35
- setExitCodeIfNot(exitCode);
36
- if (!shuttingDown) {
37
- shuttingDown = 1;
38
- ensureDisposeGlobal().finally(() => {
39
- shutdown_immediate(getCurrentCode());
40
- });
41
- }
42
- else {
43
- shuttingDown++;
44
- }
45
- }
46
- const typed_error_handlers = new WeakMap();
47
- const inherit_error_handlers = new Map();
48
- export function registerNodejsGlobalTypedErrorHandlerWithInheritance(ErrorCls, fn) {
49
- if (typed_error_handlers.has(ErrorCls)) {
50
- throw new ErrorCls(`conflict register of error type ${ErrorCls.name}`);
51
- }
52
- assert.notEqual(ErrorCls, Error, 'cannot register basic Error type');
53
- inherit_error_handlers.set(ErrorCls, fn);
54
- }
55
- export function registerNodejsGlobalTypedErrorHandler(ErrorCls, fn) {
56
- if (typed_error_handlers.has(ErrorCls)) {
57
- throw new ErrorCls(`conflict register of error type ${ErrorCls.name}`);
58
- }
59
- assert.notEqual(ErrorCls, Error, 'cannot register basic Error type');
60
- typed_error_handlers.set(ErrorCls, fn);
61
- }
62
- function _root_cause(e) {
63
- if (e.cause instanceof Error) {
64
- return _root_cause(e.cause);
65
- }
66
- return e;
67
- }
68
- function uniqueErrorHandler(currentError, logger) {
69
- if (!isProductionMode)
70
- logger.verbose?.(`uniqueErrorHandler:`);
71
- if (!(currentError instanceof Error)) {
72
- prettyPrintError(`${prefix}catch unexpect object`, new Error(`error object is ${typeof currentError} ${currentError ? currentError.constructor?.name : 'unknown'}`));
73
- throw shutdown_immediate(ExitCode.PROGRAM);
74
- }
75
- const rootCause = _root_cause(currentError);
76
- if (rootCause instanceof Exit) {
77
- if (!isProductionMode)
78
- logger.verbose?.(` - skip exit object`);
79
- if (!shuttingDown)
80
- _shutdown_graceful(rootCause.code);
81
- throw rootCause;
82
- }
83
- try {
84
- const catcher = typed_error_handlers.get(rootCause.constructor);
85
- if (catcher) {
86
- if (!isProductionMode)
87
- logger.verbose?.(` - call catcher ${functionName(catcher)}`);
88
- catcher(rootCause);
89
- return;
90
- }
91
- for (const [Cls, fn] of inherit_error_handlers) {
92
- if (!isProductionMode)
93
- logger.verbose?.(` - call inherited catcher ${functionName(fn)}`);
94
- if (rootCause instanceof Cls) {
95
- fn(rootCause);
96
- return;
97
- }
98
- }
99
- }
100
- catch (ee) {
101
- if (ee instanceof Exit)
102
- return;
103
- prettyPrintError(`${prefix}error while handle error`, {
104
- message: ee.message,
105
- stack: ee.stack,
106
- cause: rootCause,
107
- });
108
- return;
109
- }
110
- if (rootCause instanceof InterruptError) {
111
- if (!isProductionMode)
112
- logger.verbose?.(` - shuttingDown = ${shuttingDown}`);
113
- const signal = rootCause.signal;
114
- if (signal === 'SIGINT') {
115
- process.stderr.write(shuttingDown === 0 ? '\n' : '\r');
116
- }
117
- if (shuttingDown > 4) {
118
- logger.output(`${prefix}Received ${signal} more than 5 times. Exiting immediately.`);
119
- shutdown_immediate(ExitCode.INTERRUPT);
120
- }
121
- else if (shuttingDown > 0) {
122
- logger.output(`${prefix}Received ${signal} ${shuttingDown + 1} times.`);
123
- }
124
- else {
125
- logger.output(`${prefix}Received ${signal}. Exiting gracefully...`);
126
- }
127
- shutdown(ExitCode.INTERRUPT);
128
- }
129
- if (currentError instanceof UnhandledRejection) {
130
- if (!isProductionMode)
131
- logger.verbose?.(` - UnhandledRejection`);
132
- if (rootCause !== currentError) {
133
- prettyPrintError(`${prefix}Unhandled Rejection`, currentError.cause);
134
- }
135
- else {
136
- logger.output(`${prefix}Unhandled Rejection / error type unknown: ${inspect(currentError.cause)}`);
137
- }
138
- return;
139
- }
140
- if (currentError instanceof UncaughtException) {
141
- if (!isProductionMode)
142
- logger.verbose?.(` - UncaughtException`);
143
- if (rootCause !== currentError) {
144
- prettyPrintError(`${prefix}Unhandled Exception`, currentError.cause);
145
- }
146
- else {
147
- logger.output(`${prefix}Unhandled Exception / error type unknown: ${inspect(currentError.cause)}`);
148
- }
149
- return;
150
- }
151
- if (!isProductionMode)
152
- logger.verbose?.(` - common error`);
153
- prettyPrintError(`${prefix}unhandled global exception`, currentError);
154
- shutdown(ExitCode.PROGRAM);
155
- }
156
- /**
157
- * 注册nodejs退出处理器
158
- */
159
- export function registerNodejsExitHandler(logger = { output: console.error }) {
160
- ensureGlobalObject('exithandler/register', () => _real_register(logger));
161
- }
162
- function _real_register(logger) {
163
- logger.verbose?.(`register nodejs exit handler: production=${isProductionMode}`);
164
- process.on('SIGINT', () => signal_handler('SIGINT'));
165
- process.on('SIGTERM', () => signal_handler('SIGTERM'));
166
- function signal_handler(signal) {
167
- setImmediate(() => {
168
- uniqueErrorHandler(new InterruptError(signal, { boundary: signal_handler }), logger);
169
- });
170
- }
171
- process.on('beforeExit', (code) => {
172
- // empty handler prevent real exit
173
- if (!isProductionMode)
174
- logger.verbose?.(`process: beforeExit: ${code}`);
175
- if (process.exitCode === undefined || process.exitCode === '') {
176
- code = ExitCode.EXECUTION;
177
- logger.output(`${prefix}beforeExit called, but process.exitCode has not been set, switch to ${code}`);
178
- }
179
- _shutdown_graceful(code);
180
- });
181
- function finalThrow(e) {
182
- try {
183
- uniqueErrorHandler(e, logger);
184
- if (e.cause instanceof ErrorWithCode) {
185
- if (!isProductionMode)
186
- logger.verbose?.(`finalThrow: got code: ${e.cause.code}`);
187
- _shutdown_graceful(e.cause.code);
188
- }
189
- else {
190
- if (!isProductionMode)
191
- logger.verbose?.(`finalThrow: not got code: ${e.cause} `);
192
- _shutdown_graceful(ExitCode.PROGRAM);
193
- }
194
- }
195
- catch (ee) {
196
- if (ee instanceof Exit) {
197
- return;
198
- }
199
- prettyPrintError('Exception while handling error', ee);
200
- shutdown_immediate(ExitCode.PROGRAM);
201
- }
202
- }
203
- process.on('unhandledRejection', (reason, promise) => {
204
- finalThrow(new UnhandledRejection(reason, promise));
205
- });
206
- function uncaughtException(error) {
207
- finalThrow(new UncaughtException(error));
208
- }
209
- if (process.hasUncaughtExceptionCaptureCallback()) {
210
- process.on('uncaughtException', uncaughtException);
211
- throw new Error(`${prefix} [uncaught exception capture] callback already registered by other module`);
212
- }
213
- process.setUncaughtExceptionCaptureCallback(uncaughtException);
214
- process.exit = shutdown;
215
- syncBuiltinESMExports();
216
- return true;
217
- }
218
- /**
219
- * @deprecated 仅用于测试
220
- */
221
- export function die(message) {
222
- debugger;
223
- console.error(`${prefix}DIE!`, message);
224
- shutdown(1);
225
- }
226
- //# sourceMappingURL=register.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/lifecycle/register.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAE9D,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAA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