@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
- const promise = Reflect.construct(target, args);
60
- // abort 이벤트 리스너 추가하여 Promise를 즉시 reject
61
- const wrappedPromise = new Promise((resolve, reject) => {
62
- const checkAbort = () => {
63
- if (abortSignal.aborted) {
64
- reject(new Error(`REQUEST_ABORTED: Promise가 중단되었습니다 (${contextId})`));
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
- // abort 이벤트 리스너 등록
68
- abortSignal.addEventListener('abort', checkAbort);
69
- // 원본 promise가 완료될 때까지 기다림
70
- promise
71
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
- .then((result) => {
73
- abortSignal.removeEventListener('abort', checkAbort);
74
- resolve(result);
75
- })
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
- .catch((error) => {
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(wrappedPromise);
92
- // Promise 완료 시 추적에서 제거
93
- wrappedPromise.finally(() => {
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(wrappedPromise);
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 wrappedPromise.then((result) => {
125
+ return promise.then((result) => {
99
126
  // 컨텍스트가 여전히 유효한지 확인
100
127
  const currentContextCheck = abort_context_1.AbortContext.getCurrentContext();
101
128
  if (!currentContextCheck || currentContextCheck.requestId !== contextId) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.7.44-slowquery.6",
3
+ "version": "1.7.44-slowquery.7",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",