@yolo-croket-dev/core 1.7.38-slowquery.4 → 1.7.38-slowquery.6

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,9 +1,7 @@
1
1
  export declare class ContextPromisePatch {
2
2
  private static isPatched;
3
3
  private static originalPromise;
4
- private static originalSetTimeout;
5
4
  static patch(): void;
6
5
  private static patchPromise;
7
- private static patchSetTimeout;
8
6
  static unpatch(): void;
9
7
  }
@@ -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
- this.originalSetTimeout = global.setTimeout;
109
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
110
- global.setTimeout = (callback, delay, ...args) => {
111
- const currentContext = abort_context_1.AbortContext.getCurrentContext();
112
- if (!currentContext) {
113
- return this.originalSetTimeout(callback, delay, ...args);
114
- }
115
- const abortSignal = currentContext.abortSignal;
116
- const contextId = currentContext.requestId;
117
- if (abortSignal.aborted) {
118
- throw new Error(`REQUEST_ABORTED: setTimeout이 중단되었습니다 (${contextId})`);
119
- }
120
- const wrappedCallback = () => {
121
- // 컨텍스트가 여전히 유효한지 확인
122
- const currentContextCheck = abort_context_1.AbortContext.getCurrentContext();
123
- if (!currentContextCheck || currentContextCheck.requestId !== contextId) {
124
- // 컨텍스트가 변경되었으면 원본 콜백 실행
125
- // eslint-disable-next-line prefer-spread
126
- callback.apply(null, args);
127
- return;
128
- }
129
- if (abortSignal.aborted) {
130
- throw new Error(`REQUEST_ABORTED: setTimeout 콜백이 중단되었습니다 (${contextId})`);
131
- }
132
- // eslint-disable-next-line prefer-spread
133
- callback.apply(null, args);
134
- };
135
- const timerId = this.originalSetTimeout(wrappedCallback, delay, ...args);
136
- // 중단 이벤트 리스너 등록
137
- const abortHandler = () => {
138
- clearTimeout(timerId);
139
- };
140
- abortSignal.addEventListener('abort', abortHandler, { once: true });
141
- abort_context_1.AbortContext.updateContext({
142
- abortHandler,
143
- timerId,
144
- });
145
- return timerId;
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
  }
@@ -362,9 +362,12 @@ let RPCInterceptor = RPCInterceptor_1 = class RPCInterceptor {
362
362
  }), (0, operators_1.finalize)(() => {
363
363
  this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
364
364
  console.log('finalize called', execInterceptor.traceId);
365
+ console.log('before endContext', context);
365
366
  functions_1.AbortContext.endContext(context);
367
+ console.log('after endContext');
368
+ functions_1.AbortContext.endContext();
366
369
  abortController = null;
367
- return new rxjs_1.Observable();
370
+ return rxjs_1.EMPTY;
368
371
  })));
369
372
  }
370
373
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.7.38-slowquery.4",
3
+ "version": "1.7.38-slowquery.6",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",