@yolo-croket-dev/core 1.7.44-slowquery.2 → 1.7.44-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.
@@ -5,6 +5,19 @@ export declare class ContextPromisePatch {
5
5
  private static originalSetInterval;
6
6
  private static originalClearTimeout;
7
7
  private static originalClearInterval;
8
+ private static activeAbortListeners;
9
+ /**
10
+ * abort 리스너를 추적
11
+ */
12
+ static registerAbortListener(contextId: string): void;
13
+ /**
14
+ * abort 리스너 완료
15
+ */
16
+ static unregisterAbortListener(contextId: string): void;
17
+ /**
18
+ * 특정 컨텍스트의 모든 abort 리스너가 완료될 때까지 대기
19
+ */
20
+ static waitForAbortListeners(contextId: string, timeout?: number): Promise<void>;
8
21
  static patch(): void;
9
22
  private static patchPromise;
10
23
  private static patchTimeouts;
@@ -3,6 +3,36 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ContextPromisePatch = void 0;
4
4
  const abort_context_1 = require("./abort-context");
5
5
  class ContextPromisePatch {
6
+ /**
7
+ * abort 리스너를 추적
8
+ */
9
+ static registerAbortListener(contextId) {
10
+ this.activeAbortListeners.add(contextId);
11
+ }
12
+ /**
13
+ * abort 리스너 완료
14
+ */
15
+ static unregisterAbortListener(contextId) {
16
+ this.activeAbortListeners.delete(contextId);
17
+ }
18
+ /**
19
+ * 특정 컨텍스트의 모든 abort 리스너가 완료될 때까지 대기
20
+ */
21
+ static async waitForAbortListeners(contextId, timeout = 1000) {
22
+ const startTime = Date.now();
23
+ while (this.activeAbortListeners.has(contextId)) {
24
+ if (Date.now() - startTime > timeout) {
25
+ // 타임아웃
26
+ break;
27
+ }
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ await new Promise((resolve) => {
30
+ setTimeout(() => {
31
+ resolve();
32
+ }, 10);
33
+ });
34
+ }
35
+ }
6
36
  static patch() {
7
37
  if (this.isPatched) {
8
38
  return;
@@ -153,8 +183,13 @@ class ContextPromisePatch {
153
183
  abortSignal,
154
184
  });
155
185
  const onAbort = () => {
156
- this.originalClearTimeout(timeoutId);
157
- activeTimers.delete(timeoutId);
186
+ ContextPromisePatch.registerAbortListener(contextId);
187
+ // 비동기로 처리해서 이벤트 루프에서 실행되도록 함
188
+ setTimeout(() => {
189
+ this.originalClearTimeout(timeoutId);
190
+ activeTimers.delete(timeoutId);
191
+ ContextPromisePatch.unregisterAbortListener(contextId);
192
+ }, 0);
158
193
  };
159
194
  abortSignal.addEventListener('abort', onAbort, { once: true });
160
195
  return timeoutId;
@@ -200,8 +235,13 @@ class ContextPromisePatch {
200
235
  abortSignal,
201
236
  });
202
237
  const onAbort = () => {
203
- this.originalClearInterval(intervalId);
204
- activeTimers.delete(intervalId);
238
+ ContextPromisePatch.registerAbortListener(contextId);
239
+ // 비동기로 처리해서 이벤트 루프에서 실행되도록 함
240
+ setTimeout(() => {
241
+ this.originalClearInterval(intervalId);
242
+ activeTimers.delete(intervalId);
243
+ ContextPromisePatch.unregisterAbortListener(contextId);
244
+ }, 0);
205
245
  };
206
246
  abortSignal.addEventListener('abort', onAbort, { once: true });
207
247
  return intervalId;
@@ -233,3 +273,5 @@ class ContextPromisePatch {
233
273
  }
234
274
  exports.ContextPromisePatch = ContextPromisePatch;
235
275
  ContextPromisePatch.isPatched = false;
276
+ // abort 리스너 추적
277
+ ContextPromisePatch.activeAbortListeners = new Set();
@@ -358,7 +358,7 @@ let RPCInterceptor = class RPCInterceptor {
358
358
  }), (0, operators_1.finalize)(async () => {
359
359
  this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
360
360
  // abort 이벤트 리스너가 모두 완료될 때까지 기다림
361
- await functions_1.AbortContext.waitForAbortHandlers(execInterceptor.traceId);
361
+ await context_promise_patch_1.ContextPromisePatch.waitForAbortListeners(execInterceptor.traceId);
362
362
  functions_1.AbortContext.disable();
363
363
  abortController = null;
364
364
  return rxjs_1.EMPTY;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.7.44-slowquery.2",
3
+ "version": "1.7.44-slowquery.3",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",