@yolo-croket-dev/core 1.7.44-slowquery.6 → 1.7.44-slowquery.7
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.
|
@@ -56,46 +56,73 @@ class ContextPromisePatch {
|
|
|
56
56
|
if (abortSignal.aborted) {
|
|
57
57
|
return Promise.reject(new Error(`REQUEST_ABORTED: Promise가 중단되었습니다 (${contextId})`));
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
//
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
// Promise 생성
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
61
|
+
let promise;
|
|
62
|
+
// executor 함수를 래핑하여 abort 체크 추가
|
|
63
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
64
|
+
const originalExecutor = args[0];
|
|
65
|
+
if (originalExecutor) {
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
const wrappedExecutor = (resolve, reject) => {
|
|
68
|
+
// abort 체크 함수
|
|
69
|
+
const checkAbort = () => {
|
|
70
|
+
if (abortSignal.aborted) {
|
|
71
|
+
reject(new Error(`REQUEST_ABORTED: Promise가 중단되었습니다 (${contextId})`));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
// abort 이벤트 리스너 등록
|
|
75
|
+
abortSignal.addEventListener('abort', checkAbort, { once: false });
|
|
76
|
+
// 원본 executor 호출
|
|
77
|
+
try {
|
|
78
|
+
originalExecutor(
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
80
|
+
(value) => {
|
|
81
|
+
abortSignal.removeEventListener('abort', checkAbort);
|
|
82
|
+
resolve(value);
|
|
83
|
+
},
|
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
|
+
(reason) => {
|
|
86
|
+
abortSignal.removeEventListener('abort', checkAbort);
|
|
87
|
+
reject(reason);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
abortSignal.removeEventListener('abort', checkAbort);
|
|
92
|
+
reject(error);
|
|
65
93
|
}
|
|
66
94
|
};
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
abortSignal.removeEventListener('abort', checkAbort);
|
|
79
|
-
reject(error);
|
|
80
|
-
});
|
|
81
|
-
// 이미 abort된 경우
|
|
82
|
-
if (abortSignal.aborted) {
|
|
83
|
-
abortSignal.removeEventListener('abort', checkAbort);
|
|
84
|
-
reject(new Error(`REQUEST_ABORTED: Promise가 중단되었습니다 (${contextId})`));
|
|
85
|
-
}
|
|
86
|
-
});
|
|
95
|
+
// 새로운 args 배열 생성
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
97
|
+
const newArgs = [
|
|
98
|
+
wrappedExecutor,
|
|
99
|
+
...args.slice(1),
|
|
100
|
+
];
|
|
101
|
+
promise = Reflect.construct(target, newArgs);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
promise = Reflect.construct(target, args);
|
|
105
|
+
}
|
|
87
106
|
// Promise 추적 추가
|
|
88
107
|
if (!ContextPromisePatch.contextPromises.has(contextId)) {
|
|
89
108
|
ContextPromisePatch.contextPromises.set(contextId, new Set());
|
|
90
109
|
}
|
|
91
|
-
ContextPromisePatch.contextPromises.get(contextId).add(
|
|
92
|
-
// Promise
|
|
93
|
-
|
|
110
|
+
ContextPromisePatch.contextPromises.get(contextId).add(promise);
|
|
111
|
+
// abort 이벤트 리스너 등록 (Promise가 abort되면 추적에서 제거하도록)
|
|
112
|
+
const abortListener = () => {
|
|
113
|
+
var _a;
|
|
114
|
+
// Promise가 abort되었을 때 추적에서 제거
|
|
115
|
+
(_a = ContextPromisePatch.contextPromises.get(contextId)) === null || _a === void 0 ? void 0 : _a.delete(promise);
|
|
116
|
+
};
|
|
117
|
+
abortSignal.addEventListener('abort', abortListener, { once: true });
|
|
118
|
+
// Promise 완료 시 추적에서 제거 및 리스너 해제
|
|
119
|
+
promise.finally(() => {
|
|
94
120
|
var _a;
|
|
95
|
-
(_a = ContextPromisePatch.contextPromises.get(contextId)) === null || _a === void 0 ? void 0 : _a.delete(
|
|
121
|
+
(_a = ContextPromisePatch.contextPromises.get(contextId)) === null || _a === void 0 ? void 0 : _a.delete(promise);
|
|
122
|
+
abortSignal.removeEventListener('abort', abortListener);
|
|
96
123
|
});
|
|
97
124
|
// Promise 체인에 자동으로 중단 확인 추가
|
|
98
|
-
return
|
|
125
|
+
return promise.then((result) => {
|
|
99
126
|
// 컨텍스트가 여전히 유효한지 확인
|
|
100
127
|
const currentContextCheck = abort_context_1.AbortContext.getCurrentContext();
|
|
101
128
|
if (!currentContextCheck || currentContextCheck.requestId !== contextId) {
|