@yolo-croket-dev/core 1.7.25-slowquery.24 → 1.7.25-slowquery.26
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.
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbortEvent = void 0;
|
|
4
|
+
// src/modules/rpc-testing/decorators/abort-event.decorator.ts
|
|
5
|
+
const abort_1 = require("../functions/abort");
|
|
6
|
+
/**
|
|
7
|
+
* 이벤트 기반으로 AbortSignal을 감지하는 데코레이터 (Interval 없음)
|
|
8
|
+
*/
|
|
9
|
+
function AbortEvent() {
|
|
10
|
+
return function (target, propertyKey, descriptor) {
|
|
11
|
+
const originalMethod = descriptor.value;
|
|
12
|
+
// eslint-disable-next-line no-param-reassign
|
|
13
|
+
descriptor.value = async function (...args) {
|
|
14
|
+
const abortSignal = (0, abort_1.getCurrentAbortSignal)();
|
|
15
|
+
if (!abortSignal) {
|
|
16
|
+
return originalMethod.apply(this, args);
|
|
17
|
+
}
|
|
18
|
+
// 이미 중단된 경우
|
|
19
|
+
if (abortSignal.aborted) {
|
|
20
|
+
throw new Error('REQUEST_ABORTED: 작업이 이미 중단되었습니다');
|
|
21
|
+
}
|
|
22
|
+
// Promise.race로 중단 감지
|
|
23
|
+
const workPromise = originalMethod.apply(this, args);
|
|
24
|
+
const abortPromise = new Promise((_, reject) => {
|
|
25
|
+
const abortHandler = () => {
|
|
26
|
+
reject(new Error('REQUEST_ABORTED: 작업이 중단되었습니다'));
|
|
27
|
+
};
|
|
28
|
+
abortSignal.addEventListener('abort', abortHandler, { once: true });
|
|
29
|
+
});
|
|
30
|
+
return Promise.race([
|
|
31
|
+
workPromise,
|
|
32
|
+
abortPromise,
|
|
33
|
+
]);
|
|
34
|
+
};
|
|
35
|
+
return descriptor;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
exports.AbortEvent = AbortEvent;
|
package/decorators/index.d.ts
CHANGED
package/decorators/index.js
CHANGED
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./rpc-interceptor-scope.decorator"), exports);
|
|
18
18
|
__exportStar(require("./rpc-transform.decorator"), exports);
|
|
19
|
+
__exportStar(require("./abort-event.decorator"), exports);
|