@yolo-croket-dev/core 1.7.25-slowquery.35 → 1.7.25-slowquery.37
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/decorators/index.d.ts +0 -1
- package/decorators/index.js +0 -1
- package/functions/abort/enhanced-promise-patch.d.ts +0 -5
- package/functions/abort/enhanced-promise-patch.js +0 -60
- package/functions/abort/index.d.ts +1 -0
- package/functions/abort/index.js +1 -0
- package/interceptors/rpc.interceptor.js +0 -14
- package/package.json +1 -2
- package/decorators/abort-event.decorator.d.ts +0 -4
- package/decorators/abort-event.decorator.js +0 -70
package/decorators/index.d.ts
CHANGED
package/decorators/index.js
CHANGED
|
@@ -16,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./rpc-interceptor-scope.decorator"), exports);
|
|
18
18
|
__exportStar(require("./rpc-transform.decorator"), exports);
|
|
19
|
-
__exportStar(require("./abort-event.decorator"), exports);
|
|
@@ -1,41 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.EnhancedPromisePatch = void 0;
|
|
27
|
-
// packages/core/functions/abort/enhanced-promise-patch.ts
|
|
28
4
|
const abort_1 = require("./abort");
|
|
29
5
|
class EnhancedPromisePatch {
|
|
30
6
|
static patch() {
|
|
31
7
|
if (this.isPatched) {
|
|
32
8
|
return;
|
|
33
9
|
}
|
|
34
|
-
console.log('Enhanced Promise Patch 시작...');
|
|
35
10
|
this.patchPromise();
|
|
36
11
|
this.patchSetTimeout();
|
|
37
12
|
this.isPatched = true;
|
|
38
|
-
console.log('Enhanced Promise Patch 적용 완료');
|
|
39
13
|
}
|
|
40
14
|
static patchPromise() {
|
|
41
15
|
this.originalPromise = global.Promise;
|
|
@@ -128,7 +102,6 @@ class EnhancedPromisePatch {
|
|
|
128
102
|
global.Promise = this.originalPromise;
|
|
129
103
|
global.setTimeout = this.originalSetTimeout;
|
|
130
104
|
this.isPatched = false;
|
|
131
|
-
console.log('Enhanced Promise Patch 복원 완료');
|
|
132
105
|
}
|
|
133
106
|
/**
|
|
134
107
|
* 현재 패치 상태 확인
|
|
@@ -137,39 +110,6 @@ class EnhancedPromisePatch {
|
|
|
137
110
|
static getPatchStatus() {
|
|
138
111
|
return this.isPatched;
|
|
139
112
|
}
|
|
140
|
-
/**
|
|
141
|
-
* 패치된 Promise가 중단 가능한지 테스트
|
|
142
|
-
* @returns 테스트 결과
|
|
143
|
-
*/
|
|
144
|
-
static async testAbortablePromise() {
|
|
145
|
-
try {
|
|
146
|
-
const abortController = new AbortController();
|
|
147
|
-
// AbortContext를 설정하여 테스트
|
|
148
|
-
const { AbortContext } = await Promise.resolve().then(() => __importStar(require('./abort-context')));
|
|
149
|
-
return new Promise((resolve) => {
|
|
150
|
-
AbortContext.run(abortController.signal, 'test', () => {
|
|
151
|
-
const promise = new Promise((resolve) => {
|
|
152
|
-
setTimeout(() => resolve('완료'), 1000);
|
|
153
|
-
});
|
|
154
|
-
// 500ms 후 중단
|
|
155
|
-
setTimeout(() => {
|
|
156
|
-
abortController.abort();
|
|
157
|
-
}, 500);
|
|
158
|
-
promise
|
|
159
|
-
.then(() => {
|
|
160
|
-
resolve(false); // 중단되지 않았음
|
|
161
|
-
})
|
|
162
|
-
.catch((error) => {
|
|
163
|
-
resolve(error.message.includes('REQUEST_ABORTED')); // 중단됨
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
console.error('테스트 실패:', error);
|
|
170
|
-
return false;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
113
|
}
|
|
174
114
|
exports.EnhancedPromisePatch = EnhancedPromisePatch;
|
|
175
115
|
EnhancedPromisePatch.isPatched = false;
|
package/functions/abort/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./abort"), exports);
|
|
18
18
|
__exportStar(require("./abort-context"), exports);
|
|
19
|
+
__exportStar(require("./enhanced-promise-patch"), exports);
|
|
@@ -297,32 +297,19 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
297
297
|
.pipe((0, operators_1.timeout)({
|
|
298
298
|
each: this.DEFAULT_TIMEOUT,
|
|
299
299
|
with: () => {
|
|
300
|
-
console.log('RPCInterceptor timeout 발생');
|
|
301
300
|
msaLogger.error('RPCInterceptor timeout 발생', { traceId: execInterceptor.traceId }, { message: this.DEFAULT_TIMEOUT_MESSAGE });
|
|
302
301
|
abortController.abort();
|
|
303
302
|
return (0, rxjs_1.throwError)(() => new Error(this.DEFAULT_TIMEOUT_MESSAGE));
|
|
304
303
|
},
|
|
305
304
|
}), (0, operators_1.catchError)((error) => {
|
|
306
|
-
// eslint-disable-next-line no-console
|
|
307
|
-
console.log('AbortInterceptor: 에러 발생', {
|
|
308
|
-
error: error.message,
|
|
309
|
-
isAborted: abortController.signal.aborted,
|
|
310
|
-
});
|
|
311
305
|
// abort된 경우와 일반 에러를 구분
|
|
312
306
|
if (abortController.signal.aborted) {
|
|
313
|
-
// 추가되어야 하는가?
|
|
314
307
|
return (0, rxjs_1.throwError)(() => new Error(`REQUEST_ABORTED: ${this.DEFAULT_TIMEOUT_MESSAGE}`));
|
|
315
308
|
}
|
|
316
309
|
return (0, rxjs_1.throwError)(() => error);
|
|
317
310
|
}), (0, operators_1.tap)({
|
|
318
311
|
next: async (val) => {
|
|
319
312
|
val.isError = false;
|
|
320
|
-
// const duration = Date.now() - now;
|
|
321
|
-
// logger.debug(`<= (success:${traceId}): ${val.message}`, {
|
|
322
|
-
// ...logParam,
|
|
323
|
-
// duration,
|
|
324
|
-
// isError: val.isError,
|
|
325
|
-
// });
|
|
326
313
|
/** 만약 응답데이터중 isRequeue가 true라면, 다시 재처리 하도록 함 */
|
|
327
314
|
if (val.data && val.data.isRequeue) {
|
|
328
315
|
channel.nack(message, false, true);
|
|
@@ -339,7 +326,6 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
339
326
|
// eslint-disable-next-line consistent-return
|
|
340
327
|
(0, operators_1.catchError)(async (err) => {
|
|
341
328
|
// timeout 에러 처리
|
|
342
|
-
console.log('RPCInterceptor catchError 발생', err);
|
|
343
329
|
const isTimeoutError = err instanceof Error && (err.name === 'TimeoutError' || err.message === this.DEFAULT_TIMEOUT_MESSAGE);
|
|
344
330
|
if (isTimeoutError) {
|
|
345
331
|
msaLogger.error('[타임 아웃] 메시지 재전송 처리', { traceId: execInterceptor.traceId }, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yolo-croket-dev/core",
|
|
3
|
-
"version": "1.7.25-slowquery.
|
|
3
|
+
"version": "1.7.25-slowquery.37",
|
|
4
4
|
"author": "Yolo Co., Ltd.",
|
|
5
5
|
"description": "Yolo commonization module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"license": "UNLICENSED",
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@nestjs/common": "^8.2.3",
|
|
18
|
-
"@xuchaoqian/abortable-promise": "^1.11.2",
|
|
19
18
|
"@yolo-croket-dev/logger": "^1.0.15",
|
|
20
19
|
"@yolo-croket-dev/msa-logger": "^3.0.4",
|
|
21
20
|
"@yolo-croket-dev/redis": "^1.0.23",
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbortEvent = void 0;
|
|
4
|
-
// src/modules/rpc-testing/decorators/abort-event.decorator.ts
|
|
5
|
-
const abort_1 = require("../functions/abort");
|
|
6
|
-
// import { AbortablePromise } from '@xuchaoqian/abortable-promise';
|
|
7
|
-
/**
|
|
8
|
-
* 이벤트 기반으로 AbortSignal을 감지하는 데코레이터 (Interval 없음)
|
|
9
|
-
*/
|
|
10
|
-
function AbortEvent() {
|
|
11
|
-
return function (target, propertyKey, descriptor) {
|
|
12
|
-
const originalMethod = descriptor.value;
|
|
13
|
-
descriptor.value = async function (...args) {
|
|
14
|
-
const abortSignal = (0, abort_1.getCurrentAbortSignal)();
|
|
15
|
-
if (!abortSignal) {
|
|
16
|
-
return originalMethod.apply(this, args);
|
|
17
|
-
}
|
|
18
|
-
if (abortSignal.aborted) {
|
|
19
|
-
throw new Error('REQUEST_ABORTED: 작업이 이미 중단되었습니다');
|
|
20
|
-
}
|
|
21
|
-
// AbortablePromise를 사용하여 실제로 중단 가능한 Promise 생성
|
|
22
|
-
return new AbortablePromise((resolve, reject) => {
|
|
23
|
-
const abortHandler = () => {
|
|
24
|
-
reject(new Error('REQUEST_ABORTED: 작업이 중단되었습니다'));
|
|
25
|
-
};
|
|
26
|
-
abortSignal.addEventListener('abort', abortHandler, { once: true });
|
|
27
|
-
// 원본 메서드 실행
|
|
28
|
-
originalMethod.apply(this, args)
|
|
29
|
-
.then((result) => {
|
|
30
|
-
abortSignal.removeEventListener('abort', abortHandler);
|
|
31
|
-
resolve(result);
|
|
32
|
-
})
|
|
33
|
-
.catch((error) => {
|
|
34
|
-
abortSignal.removeEventListener('abort', abortHandler);
|
|
35
|
-
reject(error);
|
|
36
|
-
});
|
|
37
|
-
}, abortSignal);
|
|
38
|
-
};
|
|
39
|
-
return descriptor;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
exports.AbortEvent = AbortEvent;
|
|
43
|
-
// AbortablePromise 클래스
|
|
44
|
-
class AbortablePromise extends Promise {
|
|
45
|
-
constructor(executor, signal) {
|
|
46
|
-
super((resolve, reject) => {
|
|
47
|
-
if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
|
|
48
|
-
reject(new Error('REQUEST_ABORTED: Promise가 이미 중단되었습니다'));
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const abortHandler = () => {
|
|
52
|
-
reject(new Error('REQUEST_ABORTED: Promise가 중단되었습니다'));
|
|
53
|
-
};
|
|
54
|
-
if (signal) {
|
|
55
|
-
signal.addEventListener('abort', abortHandler, { once: true });
|
|
56
|
-
}
|
|
57
|
-
executor((value) => {
|
|
58
|
-
if (signal) {
|
|
59
|
-
signal.removeEventListener('abort', abortHandler);
|
|
60
|
-
}
|
|
61
|
-
resolve(value);
|
|
62
|
-
}, (reason) => {
|
|
63
|
-
if (signal) {
|
|
64
|
-
signal.removeEventListener('abort', abortHandler);
|
|
65
|
-
}
|
|
66
|
-
reject(reason);
|
|
67
|
-
});
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|