@yolo-croket-dev/core 1.7.38-slowquery.4 → 1.7.38-slowquery.5
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.
|
@@ -3,13 +3,14 @@ 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
|
+
// private static originalSetTimeout: typeof setTimeout;
|
|
6
7
|
static patch() {
|
|
7
8
|
if (this.isPatched) {
|
|
8
9
|
return;
|
|
9
10
|
}
|
|
10
11
|
this.originalPromise = global.Promise;
|
|
11
12
|
this.patchPromise();
|
|
12
|
-
this.patchSetTimeout();
|
|
13
|
+
// this.patchSetTimeout();
|
|
13
14
|
this.isPatched = true;
|
|
14
15
|
}
|
|
15
16
|
static patchPromise() {
|
|
@@ -104,53 +105,57 @@ class ContextPromisePatch {
|
|
|
104
105
|
return originalReject.call(global.Promise, reason);
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
|
-
static patchSetTimeout() {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
108
|
+
// private static patchSetTimeout(): void {
|
|
109
|
+
// this.originalSetTimeout = global.setTimeout;
|
|
110
|
+
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
+
// (global as any).setTimeout = (callback: () => void, delay: number, ...args: unknown[]) => {
|
|
112
|
+
// const currentContext = AbortContext.getCurrentContext();
|
|
113
|
+
// if (!currentContext) {
|
|
114
|
+
// return (this.originalSetTimeout as (...args: unknown[]) => unknown)(
|
|
115
|
+
// callback,
|
|
116
|
+
// delay,
|
|
117
|
+
// ...args as [unknown],
|
|
118
|
+
// );
|
|
119
|
+
// }
|
|
120
|
+
// const abortSignal: AbortSignal = currentContext.abortSignal;
|
|
121
|
+
// const contextId: string = currentContext.requestId;
|
|
122
|
+
// if (abortSignal.aborted) {
|
|
123
|
+
// throw new Error(`REQUEST_ABORTED: setTimeout이 중단되었습니다 (${contextId})`);
|
|
124
|
+
// }
|
|
125
|
+
// const wrappedCallback = () => {
|
|
126
|
+
// // 컨텍스트가 여전히 유효한지 확인
|
|
127
|
+
// const currentContextCheck = AbortContext.getCurrentContext();
|
|
128
|
+
// if (!currentContextCheck || currentContextCheck.requestId !== contextId) {
|
|
129
|
+
// // 컨텍스트가 변경되었으면 원본 콜백 실행
|
|
130
|
+
// // eslint-disable-next-line prefer-spread
|
|
131
|
+
// callback.apply(null, args as []);
|
|
132
|
+
// return;
|
|
133
|
+
// }
|
|
134
|
+
// if (abortSignal.aborted) {
|
|
135
|
+
// throw new Error(`REQUEST_ABORTED: setTimeout 콜백이 중단되었습니다 (${contextId})`);
|
|
136
|
+
// }
|
|
137
|
+
// // eslint-disable-next-line prefer-spread
|
|
138
|
+
// callback.apply(null, args as []);
|
|
139
|
+
// };
|
|
140
|
+
// const timerId = this.originalSetTimeout(wrappedCallback, delay, ...args as []);
|
|
141
|
+
// // 중단 이벤트 리스너 등록
|
|
142
|
+
// const abortHandler = () => {
|
|
143
|
+
// clearTimeout(timerId);
|
|
144
|
+
// };
|
|
145
|
+
// abortSignal.addEventListener('abort', abortHandler, { once: true });
|
|
146
|
+
// AbortContext.updateContext({
|
|
147
|
+
// abortHandler,
|
|
148
|
+
// timerId,
|
|
149
|
+
// });
|
|
150
|
+
// return timerId;
|
|
151
|
+
// };
|
|
152
|
+
// }
|
|
148
153
|
static unpatch() {
|
|
149
154
|
if (!this.isPatched) {
|
|
150
155
|
return;
|
|
151
156
|
}
|
|
152
157
|
global.Promise = this.originalPromise;
|
|
153
|
-
global.setTimeout = this.originalSetTimeout;
|
|
158
|
+
// global.setTimeout = this.originalSetTimeout;
|
|
154
159
|
this.isPatched = false;
|
|
155
160
|
}
|
|
156
161
|
}
|