@yolo-croket-dev/core 1.7.44-slowquery.3 → 1.7.44-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.
|
@@ -5,19 +5,12 @@ export declare class ContextPromisePatch {
|
|
|
5
5
|
private static originalSetInterval;
|
|
6
6
|
private static originalClearTimeout;
|
|
7
7
|
private static originalClearInterval;
|
|
8
|
-
private static
|
|
8
|
+
private static contextTimers;
|
|
9
|
+
private static timerContextMap;
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* 특정 컨텍스트의 모든 타이머 정리
|
|
11
12
|
*/
|
|
12
|
-
static
|
|
13
|
-
/**
|
|
14
|
-
* abort 리스너 완료
|
|
15
|
-
*/
|
|
16
|
-
static unregisterAbortListener(contextId: string): void;
|
|
17
|
-
/**
|
|
18
|
-
* 특정 컨텍스트의 모든 abort 리스너가 완료될 때까지 대기
|
|
19
|
-
*/
|
|
20
|
-
static waitForAbortListeners(contextId: string, timeout?: number): Promise<void>;
|
|
13
|
+
static clearContextTimers(contextId: string): void;
|
|
21
14
|
static patch(): void;
|
|
22
15
|
private static patchPromise;
|
|
23
16
|
private static patchTimeouts;
|
|
@@ -4,33 +4,17 @@ exports.ContextPromisePatch = void 0;
|
|
|
4
4
|
const abort_context_1 = require("./abort-context");
|
|
5
5
|
class ContextPromisePatch {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* 특정 컨텍스트의 모든 타이머 정리
|
|
8
8
|
*/
|
|
9
|
-
static
|
|
10
|
-
this.
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
9
|
+
static clearContextTimers(contextId) {
|
|
10
|
+
const timers = this.contextTimers.get(contextId);
|
|
11
|
+
if (timers) {
|
|
12
|
+
for (const timerId of timers) {
|
|
13
|
+
this.originalClearTimeout(timerId);
|
|
14
|
+
this.originalClearInterval(timerId);
|
|
15
|
+
this.timerContextMap.delete(timerId);
|
|
27
16
|
}
|
|
28
|
-
|
|
29
|
-
await new Promise((resolve) => {
|
|
30
|
-
setTimeout(() => {
|
|
31
|
-
resolve();
|
|
32
|
-
}, 10);
|
|
33
|
-
});
|
|
17
|
+
this.contextTimers.delete(contextId);
|
|
34
18
|
}
|
|
35
19
|
}
|
|
36
20
|
static patch() {
|
|
@@ -182,14 +166,18 @@ class ContextPromisePatch {
|
|
|
182
166
|
contextId,
|
|
183
167
|
abortSignal,
|
|
184
168
|
});
|
|
169
|
+
// 타이머 추적
|
|
170
|
+
if (!this.contextTimers.has(contextId)) {
|
|
171
|
+
this.contextTimers.set(contextId, new Set());
|
|
172
|
+
}
|
|
173
|
+
this.contextTimers.get(contextId).add(timeoutId);
|
|
174
|
+
this.timerContextMap.set(timeoutId, contextId);
|
|
185
175
|
const onAbort = () => {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
ContextPromisePatch.unregisterAbortListener(contextId);
|
|
192
|
-
}, 0);
|
|
176
|
+
var _a;
|
|
177
|
+
this.originalClearTimeout(timeoutId);
|
|
178
|
+
activeTimers.delete(timeoutId);
|
|
179
|
+
(_a = this.contextTimers.get(contextId)) === null || _a === void 0 ? void 0 : _a.delete(timeoutId);
|
|
180
|
+
this.timerContextMap.delete(timeoutId);
|
|
193
181
|
};
|
|
194
182
|
abortSignal.addEventListener('abort', onAbort, { once: true });
|
|
195
183
|
return timeoutId;
|
|
@@ -234,14 +222,18 @@ class ContextPromisePatch {
|
|
|
234
222
|
contextId,
|
|
235
223
|
abortSignal,
|
|
236
224
|
});
|
|
225
|
+
// 타이머 추적
|
|
226
|
+
if (!this.contextTimers.has(contextId)) {
|
|
227
|
+
this.contextTimers.set(contextId, new Set());
|
|
228
|
+
}
|
|
229
|
+
this.contextTimers.get(contextId).add(intervalId);
|
|
230
|
+
this.timerContextMap.set(intervalId, contextId);
|
|
237
231
|
const onAbort = () => {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
ContextPromisePatch.unregisterAbortListener(contextId);
|
|
244
|
-
}, 0);
|
|
232
|
+
var _a;
|
|
233
|
+
this.originalClearInterval(intervalId);
|
|
234
|
+
activeTimers.delete(intervalId);
|
|
235
|
+
(_a = this.contextTimers.get(contextId)) === null || _a === void 0 ? void 0 : _a.delete(intervalId);
|
|
236
|
+
this.timerContextMap.delete(intervalId);
|
|
245
237
|
};
|
|
246
238
|
abortSignal.addEventListener('abort', onAbort, { once: true });
|
|
247
239
|
return intervalId;
|
|
@@ -249,13 +241,25 @@ class ContextPromisePatch {
|
|
|
249
241
|
// clearTimeout 패치
|
|
250
242
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
251
243
|
global.clearTimeout = (timerId) => {
|
|
244
|
+
var _a;
|
|
252
245
|
activeTimers.delete(timerId);
|
|
246
|
+
const contextId = this.timerContextMap.get(timerId);
|
|
247
|
+
if (contextId) {
|
|
248
|
+
(_a = this.contextTimers.get(contextId)) === null || _a === void 0 ? void 0 : _a.delete(timerId);
|
|
249
|
+
this.timerContextMap.delete(timerId);
|
|
250
|
+
}
|
|
253
251
|
this.originalClearTimeout(timerId);
|
|
254
252
|
};
|
|
255
253
|
// clearInterval 패치
|
|
256
254
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
257
255
|
global.clearInterval = (timerId) => {
|
|
256
|
+
var _a;
|
|
258
257
|
activeTimers.delete(timerId);
|
|
258
|
+
const contextId = this.timerContextMap.get(timerId);
|
|
259
|
+
if (contextId) {
|
|
260
|
+
(_a = this.contextTimers.get(contextId)) === null || _a === void 0 ? void 0 : _a.delete(timerId);
|
|
261
|
+
this.timerContextMap.delete(timerId);
|
|
262
|
+
}
|
|
259
263
|
this.originalClearInterval(timerId);
|
|
260
264
|
};
|
|
261
265
|
}
|
|
@@ -273,5 +277,9 @@ class ContextPromisePatch {
|
|
|
273
277
|
}
|
|
274
278
|
exports.ContextPromisePatch = ContextPromisePatch;
|
|
275
279
|
ContextPromisePatch.isPatched = false;
|
|
276
|
-
//
|
|
277
|
-
|
|
280
|
+
// 컨텍스트별 활성 타이머 추적 (contextId -> Set<timerId>)
|
|
281
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
282
|
+
ContextPromisePatch.contextTimers = new Map();
|
|
283
|
+
// timerId -> contextId 매핑
|
|
284
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
285
|
+
ContextPromisePatch.timerContextMap = new Map();
|
|
@@ -355,10 +355,10 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
355
355
|
}
|
|
356
356
|
},
|
|
357
357
|
error: localErrorProcessor,
|
|
358
|
-
}), (0, operators_1.finalize)(
|
|
358
|
+
}), (0, operators_1.finalize)(() => {
|
|
359
359
|
this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
|
|
360
|
-
//
|
|
361
|
-
|
|
360
|
+
// 활성 타이머를 모두 정리
|
|
361
|
+
context_promise_patch_1.ContextPromisePatch.clearContextTimers(execInterceptor.traceId);
|
|
362
362
|
functions_1.AbortContext.disable();
|
|
363
363
|
abortController = null;
|
|
364
364
|
return rxjs_1.EMPTY;
|