@yolo-croket-dev/core 1.7.38-slowquery.2 → 1.7.38-slowquery.4

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.
@@ -11,7 +11,7 @@ interface RequestContext {
11
11
  export declare class AbortContext {
12
12
  private static asyncLocalStorage;
13
13
  private static contextCounter;
14
- static run<T>(abortSignal: AbortSignal, requestId: string, callback: () => T): T;
14
+ static run<T>(abortSignal: AbortSignal, requestId: string, callback: (context: RequestContext) => T): T;
15
15
  static getCurrentAbortSignal(): AbortSignal | null;
16
16
  static getCurrentRequestId(): string | null;
17
17
  static getCurrentContext(): {
@@ -12,7 +12,7 @@ class AbortContext {
12
12
  createdAt: Date.now(),
13
13
  parentContext: currentContext || undefined,
14
14
  };
15
- return this.asyncLocalStorage.run(newContext, callback);
15
+ return this.asyncLocalStorage.run(newContext, callback.bind(this, newContext));
16
16
  }
17
17
  static getCurrentAbortSignal() {
18
18
  const context = this.asyncLocalStorage.getStore();
@@ -26,7 +26,6 @@ class ContextPromisePatch {
26
26
  const contextId = currentContext.requestId;
27
27
  // 이미 중단된 경우
28
28
  if (abortSignal.aborted) {
29
- console.log('Promise 생성자 패치: 이미 중단된 경우');
30
29
  return Promise.reject(new Error(`REQUEST_ABORTED: Promise가 중단되었습니다 (${contextId})`));
31
30
  }
32
31
  const promise = Reflect.construct(target, args);
@@ -39,7 +38,6 @@ class ContextPromisePatch {
39
38
  return result;
40
39
  }
41
40
  if (abortSignal.aborted) {
42
- console.log('Promise 생성자 패치: Promise 실행 중 중단된 경우');
43
41
  throw new Error(`REQUEST_ABORTED: Promise 실행 중 중단되었습니다 (${contextId})`);
44
42
  }
45
43
  return result;
@@ -51,7 +49,6 @@ class ContextPromisePatch {
51
49
  throw error;
52
50
  }
53
51
  if (abortSignal.aborted) {
54
- console.log('Promise 생성자 패치: Promise 실행 중 중단된 경우');
55
52
  throw new Error(`REQUEST_ABORTED: Promise 실행 중 중단되었습니다 (${contextId})`);
56
53
  }
57
54
  throw error;
@@ -69,7 +66,6 @@ class ContextPromisePatch {
69
66
  const abortSignal = currentContext.abortSignal;
70
67
  const contextId = currentContext.requestId;
71
68
  if (abortSignal.aborted) {
72
- console.log('Promise 생성자 패치: Promise.resolve가 중단된 경우');
73
69
  return Promise.reject(new Error(`REQUEST_ABORTED: Promise.resolve가 중단되었습니다 (${contextId})`));
74
70
  }
75
71
  const promise = originalResolve.call(global.Promise, value);
@@ -79,7 +75,6 @@ class ContextPromisePatch {
79
75
  return result;
80
76
  }
81
77
  if (abortSignal.aborted) {
82
- console.log('Promise 생성자 패치: Promise.resolve 실행 중 중단된 경우');
83
78
  throw new Error(`REQUEST_ABORTED: Promise.resolve 실행 중 중단되었습니다 (${contextId})`);
84
79
  }
85
80
  return result;
@@ -89,7 +84,6 @@ class ContextPromisePatch {
89
84
  throw error;
90
85
  }
91
86
  if (abortSignal.aborted) {
92
- console.log('Promise 생성자 패치: Promise.resolve 실행 중 중단된 경우');
93
87
  throw new Error(`REQUEST_ABORTED: Promise.resolve 실행 중 중단되었습니다 (${contextId})`);
94
88
  }
95
89
  throw error;
@@ -105,7 +99,6 @@ class ContextPromisePatch {
105
99
  }
106
100
  const abortSignal = currentContext.abortSignal;
107
101
  if (abortSignal.aborted) {
108
- console.log('Promise 생성자 패치: Promise.reject가 중단된 경우');
109
102
  return Promise.reject(new Error(`REQUEST_ABORTED: Promise.reject가 중단되었습니다 (${currentContext.requestId})`));
110
103
  }
111
104
  return originalReject.call(global.Promise, reason);
@@ -122,7 +115,6 @@ class ContextPromisePatch {
122
115
  const abortSignal = currentContext.abortSignal;
123
116
  const contextId = currentContext.requestId;
124
117
  if (abortSignal.aborted) {
125
- console.log('Promise 생성자 패치: setTimeout이 중단된 경우');
126
118
  throw new Error(`REQUEST_ABORTED: setTimeout이 중단되었습니다 (${contextId})`);
127
119
  }
128
120
  const wrappedCallback = () => {
@@ -135,7 +127,6 @@ class ContextPromisePatch {
135
127
  return;
136
128
  }
137
129
  if (abortSignal.aborted) {
138
- console.log('Promise 생성자 패치: setTimeout 콜백이 중단된 경우');
139
130
  throw new Error(`REQUEST_ABORTED: setTimeout 콜백이 중단되었습니다 (${contextId})`);
140
131
  }
141
132
  // eslint-disable-next-line prefer-spread
@@ -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,13 +327,9 @@ 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
- return functions_1.AbortContext.run(abortController.signal, execInterceptor.traceId, () => next
332
+ return functions_1.AbortContext.run(abortController.signal, execInterceptor.traceId, (context) => next
333
333
  .handle()
334
334
  .pipe((0, operators_1.timeout)({
335
335
  each: this.DEFAULT_TIMEOUT,
@@ -361,10 +361,8 @@ 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
- }
367
- functions_1.AbortContext.endContext();
364
+ console.log('finalize called', execInterceptor.traceId);
365
+ functions_1.AbortContext.endContext(context);
368
366
  abortController = null;
369
367
  return new rxjs_1.Observable();
370
368
  })));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.7.38-slowquery.2",
3
+ "version": "1.7.38-slowquery.4",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",