@yolo-croket-dev/core 1.7.44 → 1.7.45-slowquery.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.
@@ -170,7 +170,7 @@ let RPCInterceptor = class RPCInterceptor {
170
170
  isMessageAck: false,
171
171
  };
172
172
  context_promise_patch_1.ContextPromisePatch.patch();
173
- let abortController = new AbortController();
173
+ const 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,44 +325,60 @@ 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, () => 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;
351
- }
352
- if (!noAck) {
353
- execInterceptor.isMessageAck = true;
354
- channel.ack(message);
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);
355
378
  }
356
- },
357
- error: localErrorProcessor,
358
- }), (0, operators_1.finalize)(() => {
359
- this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
360
- setTimeout(() => {
361
- functions_1.AbortContext.disable();
362
- abortController = null;
363
- }, 1000 * 10);
364
- return rxjs_1.EMPTY;
365
- })));
379
+ return rxjs_1.EMPTY;
380
+ }));
381
+ });
366
382
  }
367
383
  };
368
384
  exports.RPCInterceptor = RPCInterceptor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.7.44",
3
+ "version": "1.7.45-slowquery.1",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",