@yolo-croket-dev/core 1.7.45-slowquery.1 → 1.7.45

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.
@@ -16,7 +16,7 @@ export declare class AbortContext {
16
16
  requestId: string;
17
17
  } | null;
18
18
  static disable(): void;
19
- static endContext(context?: RequestContext): void;
19
+ static endContext(): void;
20
20
  static updateContext(updatedData: Partial<RequestContext>): void;
21
21
  /**
22
22
  * 컨텍스트가 유효한지 확인
@@ -36,16 +36,12 @@ class AbortContext {
36
36
  this.asyncLocalStorage.disable();
37
37
  }
38
38
  // 컨텍스트 종료
39
- // eslint-disable-next-line consistent-return
40
- static endContext(context) {
41
- const selectContext = context || this.asyncLocalStorage.getStore();
42
- if (selectContext) {
43
- this.asyncLocalStorage.disable();
44
- // parent context가 있으면 전부 종료
45
- if (selectContext.parentContext) {
46
- return this.endContext(selectContext.parentContext);
47
- }
48
- }
39
+ // AsyncLocalStorage는 각 async 작업의 컨텍스트를 자동으로 관리하므로
40
+ // 명시적으로 disable()을 호출할 필요가 없습니다.
41
+ // disable()을 호출하면 전체 인스턴스가 비활성화되어 이후 요청에 문제가 생깁니다.
42
+ static endContext() {
43
+ // 컨텍스트는 async 작업이 완료되면 자동으로 정리됩니다.
44
+ // 명시적인 cleanup은 필요하지 않습니다.
49
45
  }
50
46
  // 현재 컨텍스트를 업데이트하는 방법
51
47
  static updateContext(updatedData) {
@@ -170,7 +170,7 @@ let RPCInterceptor = class RPCInterceptor {
170
170
  isMessageAck: false,
171
171
  };
172
172
  context_promise_patch_1.ContextPromisePatch.patch();
173
- const abortController = new AbortController();
173
+ let abortController = new AbortController();
174
174
  /** consume 메시지 전부 cancel */
175
175
  if (this.gracefulShutdownService.isApplicationExit) {
176
176
  msaLogger.debug('RPCInterceptor isApplicationExit called', { traceId: 'IS_APPLICATION_EXIT' });
@@ -325,60 +325,46 @@ let RPCInterceptor = class RPCInterceptor {
325
325
  }
326
326
  this.gracefulShutdownService.pushActiveInterceptors(execInterceptor);
327
327
  // eslint-disable-next-line consistent-return
328
- return functions_1.AbortContext.run(abortController.signal, execInterceptor.traceId, () => {
329
- const context = functions_1.AbortContext.getCurrentContext();
330
- return next
331
- .handle()
332
- .pipe((0, operators_1.timeout)({
333
- each: this.DEFAULT_TIMEOUT,
334
- with: () => {
335
- msaLogger.error('RPCInterceptor timeout 발생', { traceId: execInterceptor.traceId }, {
336
- message: this.DEFAULT_TIMEOUT_MESSAGE,
337
- messagePattern: method,
338
- durationMs: Date.now() - now,
339
- reDeliveryCount,
340
- staticRetryCount,
341
- });
342
- abortController.abort();
343
- return (0, rxjs_1.throwError)(() => new exceptions_1.InternalServerError('TIMEOUT_ERROR', this.DEFAULT_TIMEOUT_MESSAGE));
344
- },
345
- }), (0, operators_1.tap)({
346
- next: async (val) => {
347
- val.isError = false;
348
- /** 만약 응답데이터중 isRequeue가 true라면, 다시 재처리 하도록 함 */
349
- if (val.data && val.data.isRequeue) {
350
- channel.nack(message, false, true);
351
- execInterceptor.isMessageAck = true;
352
- return;
353
- }
354
- if (!noAck) {
355
- execInterceptor.isMessageAck = true;
356
- channel.ack(message);
357
- }
358
- },
359
- error: localErrorProcessor,
360
- }), (0, operators_1.finalize)(() => {
361
- this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
362
- const isAborted = abortController === null || abortController === void 0 ? void 0 : abortController.signal.aborted;
363
- if (context) {
364
- if (isAborted) {
365
- msaLogger.debug('RPCInterceptor context end', { traceId: execInterceptor.traceId }, { context: context.requestId });
366
- }
367
- functions_1.AbortContext.endContext();
368
- // Promise 체인이 완전히 완료될 때까지 지연 후 disable
369
- // setTimeout으로 여러 번 이벤트 루프를 통과시켜서 모든 Promise.then() 체인이 완료되도록 함
370
- setTimeout(() => {
371
- setTimeout(() => {
372
- setTimeout(() => {
373
- console.log('RPCInterceptor context disable');
374
- functions_1.AbortContext.disable();
375
- }, 0);
376
- }, 0);
377
- }, 0);
328
+ return functions_1.AbortContext.run(abortController.signal, execInterceptor.traceId, () => next
329
+ .handle()
330
+ .pipe((0, operators_1.timeout)({
331
+ each: this.DEFAULT_TIMEOUT,
332
+ with: () => {
333
+ msaLogger.error('RPCInterceptor timeout 발생', { traceId: execInterceptor.traceId }, {
334
+ message: this.DEFAULT_TIMEOUT_MESSAGE,
335
+ messagePattern: method,
336
+ durationMs: Date.now() - now,
337
+ reDeliveryCount,
338
+ staticRetryCount,
339
+ });
340
+ abortController.abort();
341
+ return (0, rxjs_1.throwError)(() => new exceptions_1.InternalServerError('TIMEOUT_ERROR', this.DEFAULT_TIMEOUT_MESSAGE));
342
+ },
343
+ }), (0, operators_1.tap)({
344
+ next: async (val) => {
345
+ val.isError = false;
346
+ /** 만약 응답데이터중 isRequeue가 true라면, 다시 재처리 하도록 함 */
347
+ if (val.data && val.data.isRequeue) {
348
+ channel.nack(message, false, true);
349
+ execInterceptor.isMessageAck = true;
350
+ return;
378
351
  }
379
- return rxjs_1.EMPTY;
380
- }));
381
- });
352
+ if (!noAck) {
353
+ execInterceptor.isMessageAck = true;
354
+ channel.ack(message);
355
+ }
356
+ },
357
+ error: localErrorProcessor,
358
+ }), (0, operators_1.finalize)(() => {
359
+ this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
360
+ const isAborted = abortController === null || abortController === void 0 ? void 0 : abortController.signal.aborted;
361
+ if (isAborted) {
362
+ msaLogger.debug('RPCInterceptor context end', { traceId: execInterceptor.traceId }, { isAborted });
363
+ functions_1.AbortContext.endContext();
364
+ abortController = null;
365
+ }
366
+ return rxjs_1.EMPTY;
367
+ })));
382
368
  }
383
369
  };
384
370
  exports.RPCInterceptor = RPCInterceptor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.7.45-slowquery.1",
3
+ "version": "1.7.45",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",