@yolo-croket-dev/core 1.7.38-slowquery.1 → 1.7.38-slowquery.2
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.
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
2
3
|
interface RequestContext {
|
|
3
4
|
abortSignal: AbortSignal;
|
|
4
5
|
requestId: string;
|
|
5
6
|
createdAt: number;
|
|
6
7
|
parentContext?: RequestContext;
|
|
7
8
|
abortHandler?: () => void;
|
|
9
|
+
timerId?: NodeJS.Timeout;
|
|
8
10
|
}
|
|
9
11
|
export declare class AbortContext {
|
|
10
12
|
private static asyncLocalStorage;
|
|
@@ -36,11 +36,20 @@ class AbortContext {
|
|
|
36
36
|
// eslint-disable-next-line consistent-return
|
|
37
37
|
static endContext(context) {
|
|
38
38
|
const selectContext = context || this.asyncLocalStorage.getStore();
|
|
39
|
+
console.log('selectContext', selectContext);
|
|
39
40
|
if (selectContext) {
|
|
40
|
-
|
|
41
|
+
if (selectContext.abortHandler) {
|
|
42
|
+
console.log('selectContext.abortHandler', selectContext.abortHandler);
|
|
43
|
+
selectContext.abortSignal.removeEventListener('abort', selectContext.abortHandler || (() => { }));
|
|
44
|
+
}
|
|
45
|
+
if (selectContext.timerId) {
|
|
46
|
+
console.log('selectContext.timerId', selectContext.timerId);
|
|
47
|
+
clearTimeout(selectContext.timerId);
|
|
48
|
+
}
|
|
41
49
|
this.asyncLocalStorage.disable();
|
|
42
50
|
// parent context가 있으면 전부 종료
|
|
43
51
|
if (selectContext.parentContext) {
|
|
52
|
+
console.log('selectContext.parentContext', selectContext.parentContext);
|
|
44
53
|
return this.endContext(selectContext.parentContext);
|
|
45
54
|
}
|
|
46
55
|
}
|
|
@@ -49,6 +58,7 @@ class AbortContext {
|
|
|
49
58
|
static updateContext(updatedData) {
|
|
50
59
|
const currentContext = this.asyncLocalStorage.getStore();
|
|
51
60
|
if (!currentContext) {
|
|
61
|
+
console.log('currentContext not found');
|
|
52
62
|
return;
|
|
53
63
|
}
|
|
54
64
|
// 업데이트할 데이터만 갱신
|
|
@@ -57,6 +67,7 @@ class AbortContext {
|
|
|
57
67
|
...updatedData,
|
|
58
68
|
updatedAt: Date.now(), // `updatedAt` 값을 갱신
|
|
59
69
|
};
|
|
70
|
+
console.log('currentContext update!', currentContext, updatedContext);
|
|
60
71
|
// 업데이트된 컨텍스트를 다시 저장
|
|
61
72
|
this.asyncLocalStorage.enterWith(updatedContext);
|
|
62
73
|
}
|
|
@@ -26,6 +26,7 @@ class ContextPromisePatch {
|
|
|
26
26
|
const contextId = currentContext.requestId;
|
|
27
27
|
// 이미 중단된 경우
|
|
28
28
|
if (abortSignal.aborted) {
|
|
29
|
+
console.log('Promise 생성자 패치: 이미 중단된 경우');
|
|
29
30
|
return Promise.reject(new Error(`REQUEST_ABORTED: Promise가 중단되었습니다 (${contextId})`));
|
|
30
31
|
}
|
|
31
32
|
const promise = Reflect.construct(target, args);
|
|
@@ -38,6 +39,7 @@ class ContextPromisePatch {
|
|
|
38
39
|
return result;
|
|
39
40
|
}
|
|
40
41
|
if (abortSignal.aborted) {
|
|
42
|
+
console.log('Promise 생성자 패치: Promise 실행 중 중단된 경우');
|
|
41
43
|
throw new Error(`REQUEST_ABORTED: Promise 실행 중 중단되었습니다 (${contextId})`);
|
|
42
44
|
}
|
|
43
45
|
return result;
|
|
@@ -49,6 +51,7 @@ class ContextPromisePatch {
|
|
|
49
51
|
throw error;
|
|
50
52
|
}
|
|
51
53
|
if (abortSignal.aborted) {
|
|
54
|
+
console.log('Promise 생성자 패치: Promise 실행 중 중단된 경우');
|
|
52
55
|
throw new Error(`REQUEST_ABORTED: Promise 실행 중 중단되었습니다 (${contextId})`);
|
|
53
56
|
}
|
|
54
57
|
throw error;
|
|
@@ -66,6 +69,7 @@ class ContextPromisePatch {
|
|
|
66
69
|
const abortSignal = currentContext.abortSignal;
|
|
67
70
|
const contextId = currentContext.requestId;
|
|
68
71
|
if (abortSignal.aborted) {
|
|
72
|
+
console.log('Promise 생성자 패치: Promise.resolve가 중단된 경우');
|
|
69
73
|
return Promise.reject(new Error(`REQUEST_ABORTED: Promise.resolve가 중단되었습니다 (${contextId})`));
|
|
70
74
|
}
|
|
71
75
|
const promise = originalResolve.call(global.Promise, value);
|
|
@@ -75,6 +79,7 @@ class ContextPromisePatch {
|
|
|
75
79
|
return result;
|
|
76
80
|
}
|
|
77
81
|
if (abortSignal.aborted) {
|
|
82
|
+
console.log('Promise 생성자 패치: Promise.resolve 실행 중 중단된 경우');
|
|
78
83
|
throw new Error(`REQUEST_ABORTED: Promise.resolve 실행 중 중단되었습니다 (${contextId})`);
|
|
79
84
|
}
|
|
80
85
|
return result;
|
|
@@ -84,6 +89,7 @@ class ContextPromisePatch {
|
|
|
84
89
|
throw error;
|
|
85
90
|
}
|
|
86
91
|
if (abortSignal.aborted) {
|
|
92
|
+
console.log('Promise 생성자 패치: Promise.resolve 실행 중 중단된 경우');
|
|
87
93
|
throw new Error(`REQUEST_ABORTED: Promise.resolve 실행 중 중단되었습니다 (${contextId})`);
|
|
88
94
|
}
|
|
89
95
|
throw error;
|
|
@@ -99,6 +105,7 @@ class ContextPromisePatch {
|
|
|
99
105
|
}
|
|
100
106
|
const abortSignal = currentContext.abortSignal;
|
|
101
107
|
if (abortSignal.aborted) {
|
|
108
|
+
console.log('Promise 생성자 패치: Promise.reject가 중단된 경우');
|
|
102
109
|
return Promise.reject(new Error(`REQUEST_ABORTED: Promise.reject가 중단되었습니다 (${currentContext.requestId})`));
|
|
103
110
|
}
|
|
104
111
|
return originalReject.call(global.Promise, reason);
|
|
@@ -115,6 +122,7 @@ class ContextPromisePatch {
|
|
|
115
122
|
const abortSignal = currentContext.abortSignal;
|
|
116
123
|
const contextId = currentContext.requestId;
|
|
117
124
|
if (abortSignal.aborted) {
|
|
125
|
+
console.log('Promise 생성자 패치: setTimeout이 중단된 경우');
|
|
118
126
|
throw new Error(`REQUEST_ABORTED: setTimeout이 중단되었습니다 (${contextId})`);
|
|
119
127
|
}
|
|
120
128
|
const wrappedCallback = () => {
|
|
@@ -127,6 +135,7 @@ class ContextPromisePatch {
|
|
|
127
135
|
return;
|
|
128
136
|
}
|
|
129
137
|
if (abortSignal.aborted) {
|
|
138
|
+
console.log('Promise 생성자 패치: setTimeout 콜백이 중단된 경우');
|
|
130
139
|
throw new Error(`REQUEST_ABORTED: setTimeout 콜백이 중단되었습니다 (${contextId})`);
|
|
131
140
|
}
|
|
132
141
|
// eslint-disable-next-line prefer-spread
|
|
@@ -138,7 +147,10 @@ class ContextPromisePatch {
|
|
|
138
147
|
clearTimeout(timerId);
|
|
139
148
|
};
|
|
140
149
|
abortSignal.addEventListener('abort', abortHandler, { once: true });
|
|
141
|
-
abort_context_1.AbortContext.updateContext({
|
|
150
|
+
abort_context_1.AbortContext.updateContext({
|
|
151
|
+
abortHandler,
|
|
152
|
+
timerId,
|
|
153
|
+
});
|
|
142
154
|
return timerId;
|
|
143
155
|
};
|
|
144
156
|
}
|