@yolo-croket-dev/core 1.7.38-slowquery.1 → 1.7.38-slowquery.3

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.
@@ -1,10 +1,12 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  interface RequestContext {
3
4
  abortSignal: AbortSignal;
4
5
  requestId: string;
5
6
  createdAt: number;
6
7
  parentContext?: RequestContext;
7
8
  abortHandler?: () => void;
9
+ timerId?: NodeJS.Timeout;
8
10
  }
9
11
  export declare class AbortContext {
10
12
  private static asyncLocalStorage;
@@ -36,11 +36,20 @@ class AbortContext {
36
36
  // eslint-disable-next-line consistent-return
37
37
  static endContext(context) {
38
38
  const selectContext = context || this.asyncLocalStorage.getStore();
39
+ console.log('selectContext', selectContext);
39
40
  if (selectContext) {
40
- selectContext.abortSignal.removeEventListener('abort', selectContext.abortHandler || (() => { }));
41
+ if (selectContext.abortHandler) {
42
+ console.log('selectContext.abortHandler', selectContext.abortHandler);
43
+ selectContext.abortSignal.removeEventListener('abort', selectContext.abortHandler || (() => { }));
44
+ }
45
+ if (selectContext.timerId) {
46
+ console.log('selectContext.timerId', selectContext.timerId);
47
+ clearTimeout(selectContext.timerId);
48
+ }
41
49
  this.asyncLocalStorage.disable();
42
50
  // parent context가 있으면 전부 종료
43
51
  if (selectContext.parentContext) {
52
+ console.log('selectContext.parentContext', selectContext.parentContext);
44
53
  return this.endContext(selectContext.parentContext);
45
54
  }
46
55
  }
@@ -49,6 +58,7 @@ class AbortContext {
49
58
  static updateContext(updatedData) {
50
59
  const currentContext = this.asyncLocalStorage.getStore();
51
60
  if (!currentContext) {
61
+ console.log('currentContext not found');
52
62
  return;
53
63
  }
54
64
  // 업데이트할 데이터만 갱신
@@ -57,6 +67,7 @@ class AbortContext {
57
67
  ...updatedData,
58
68
  updatedAt: Date.now(), // `updatedAt` 값을 갱신
59
69
  };
70
+ console.log('currentContext update!', currentContext, updatedContext);
60
71
  // 업데이트된 컨텍스트를 다시 저장
61
72
  this.asyncLocalStorage.enterWith(updatedContext);
62
73
  }
@@ -138,7 +138,10 @@ class ContextPromisePatch {
138
138
  clearTimeout(timerId);
139
139
  };
140
140
  abortSignal.addEventListener('abort', abortHandler, { once: true });
141
- abort_context_1.AbortContext.updateContext({ abortHandler });
141
+ abort_context_1.AbortContext.updateContext({
142
+ abortHandler,
143
+ timerId,
144
+ });
142
145
  return timerId;
143
146
  };
144
147
  }
@@ -58,6 +58,10 @@ let RPCInterceptor = RPCInterceptor_1 = class RPCInterceptor {
58
58
  this.gracefulShutdownService = gracefulShutdownService;
59
59
  this.DEFAULT_TIMEOUT = 1000 * 60 * 29; // 29분 타임아웃
60
60
  this.DEFAULT_TIMEOUT_MESSAGE = '요청이 타임아웃되었습니다.';
61
+ if (!RPCInterceptor_1.isPatched) {
62
+ context_promise_patch_1.ContextPromisePatch.patch();
63
+ RPCInterceptor_1.isPatched = true;
64
+ }
61
65
  }
62
66
  maxLengthOverShorten(data) {
63
67
  if (typeof data !== 'string') {
@@ -323,10 +327,6 @@ let RPCInterceptor = RPCInterceptor_1 = class RPCInterceptor {
323
327
  return new rxjs_1.Observable();
324
328
  }
325
329
  }
326
- if (!RPCInterceptor_1.isPatched) {
327
- context_promise_patch_1.ContextPromisePatch.patch();
328
- RPCInterceptor_1.isPatched = true;
329
- }
330
330
  this.gracefulShutdownService.pushActiveInterceptors(execInterceptor);
331
331
  // eslint-disable-next-line consistent-return
332
332
  return functions_1.AbortContext.run(abortController.signal, execInterceptor.traceId, () => next
@@ -361,9 +361,7 @@ let RPCInterceptor = RPCInterceptor_1 = class RPCInterceptor {
361
361
  error: localErrorProcessor,
362
362
  }), (0, operators_1.finalize)(() => {
363
363
  this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
364
- if (abortController.signal) {
365
- abortController.signal.removeEventListener('abort', () => { });
366
- }
364
+ console.log('finalize called', execInterceptor.traceId);
367
365
  functions_1.AbortContext.endContext();
368
366
  abortController = null;
369
367
  return new rxjs_1.Observable();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.7.38-slowquery.1",
3
+ "version": "1.7.38-slowquery.3",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",