@yolo-croket-dev/core 1.7.25-slowquery.25 → 1.7.25-slowquery.26

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,4 @@
1
+ /**
2
+ * 이벤트 기반으로 AbortSignal을 감지하는 데코레이터 (Interval 없음)
3
+ */
4
+ export declare function AbortEvent(): (target: unknown, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;
@@ -0,0 +1,38 @@
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
+ /**
7
+ * 이벤트 기반으로 AbortSignal을 감지하는 데코레이터 (Interval 없음)
8
+ */
9
+ function AbortEvent() {
10
+ return function (target, propertyKey, descriptor) {
11
+ const originalMethod = descriptor.value;
12
+ // eslint-disable-next-line no-param-reassign
13
+ descriptor.value = async function (...args) {
14
+ const abortSignal = (0, abort_1.getCurrentAbortSignal)();
15
+ if (!abortSignal) {
16
+ return originalMethod.apply(this, args);
17
+ }
18
+ // 이미 중단된 경우
19
+ if (abortSignal.aborted) {
20
+ throw new Error('REQUEST_ABORTED: 작업이 이미 중단되었습니다');
21
+ }
22
+ // Promise.race로 중단 감지
23
+ const workPromise = originalMethod.apply(this, args);
24
+ const abortPromise = new Promise((_, reject) => {
25
+ const abortHandler = () => {
26
+ reject(new Error('REQUEST_ABORTED: 작업이 중단되었습니다'));
27
+ };
28
+ abortSignal.addEventListener('abort', abortHandler, { once: true });
29
+ });
30
+ return Promise.race([
31
+ workPromise,
32
+ abortPromise,
33
+ ]);
34
+ };
35
+ return descriptor;
36
+ };
37
+ }
38
+ exports.AbortEvent = AbortEvent;
@@ -1,2 +1,3 @@
1
1
  export * from './rpc-interceptor-scope.decorator';
2
2
  export * from './rpc-transform.decorator';
3
+ export * from './abort-event.decorator';
@@ -16,3 +16,4 @@ 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);
@@ -170,19 +170,6 @@ let RPCInterceptor = class RPCInterceptor {
170
170
  isMessageAck: false,
171
171
  };
172
172
  const abortController = new AbortController();
173
- // eslint-disable-next-line no-undef
174
- let abortCheckInterval = null;
175
- abortCheckInterval = setInterval(() => {
176
- try {
177
- (0, functions_1.throwIfAborted)();
178
- }
179
- catch (err) {
180
- if (abortCheckInterval) {
181
- clearInterval(abortCheckInterval);
182
- }
183
- throw err;
184
- }
185
- }, 1000);
186
173
  /** consume 메시지 전부 cancel */
187
174
  if (this.gracefulShutdownService.isApplicationExit) {
188
175
  msaLogger.debug('RPCInterceptor isApplicationExit called', { traceId: 'IS_APPLICATION_EXIT' });
@@ -329,9 +316,6 @@ let RPCInterceptor = class RPCInterceptor {
329
316
  return (0, rxjs_1.throwError)(() => error);
330
317
  }), (0, operators_1.tap)({
331
318
  next: async (val) => {
332
- if (abortCheckInterval) {
333
- clearInterval(abortCheckInterval);
334
- }
335
319
  val.isError = false;
336
320
  // const duration = Date.now() - now;
337
321
  // logger.debug(`<= (success:${traceId}): ${val.message}`, {
@@ -354,9 +338,6 @@ let RPCInterceptor = class RPCInterceptor {
354
338
  }),
355
339
  // eslint-disable-next-line consistent-return
356
340
  (0, operators_1.catchError)(async (err) => {
357
- if (abortCheckInterval) {
358
- clearInterval(abortCheckInterval);
359
- }
360
341
  // timeout 에러 처리
361
342
  console.log('RPCInterceptor catchError 발생', err);
362
343
  const isTimeoutError = err instanceof Error && (err.name === 'TimeoutError' || err.message === this.DEFAULT_TIMEOUT_MESSAGE);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.7.25-slowquery.25",
3
+ "version": "1.7.25-slowquery.26",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",