@yolo-croket-dev/core 1.7.44 → 1.7.45-slowquery.1
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.
- package/interceptors/rpc.interceptor.js +54 -38
- package/package.json +1 -1
|
@@ -170,7 +170,7 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
170
170
|
isMessageAck: false,
|
|
171
171
|
};
|
|
172
172
|
context_promise_patch_1.ContextPromisePatch.patch();
|
|
173
|
-
|
|
173
|
+
const abortController = new AbortController();
|
|
174
174
|
/** consume 메시지 전부 cancel */
|
|
175
175
|
if (this.gracefulShutdownService.isApplicationExit) {
|
|
176
176
|
msaLogger.debug('RPCInterceptor isApplicationExit called', { traceId: 'IS_APPLICATION_EXIT' });
|
|
@@ -325,44 +325,60 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
325
325
|
}
|
|
326
326
|
this.gracefulShutdownService.pushActiveInterceptors(execInterceptor);
|
|
327
327
|
// eslint-disable-next-line consistent-return
|
|
328
|
-
return functions_1.AbortContext.run(abortController.signal, execInterceptor.traceId, () =>
|
|
329
|
-
.
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
328
|
+
return functions_1.AbortContext.run(abortController.signal, execInterceptor.traceId, () => {
|
|
329
|
+
const context = functions_1.AbortContext.getCurrentContext();
|
|
330
|
+
return next
|
|
331
|
+
.handle()
|
|
332
|
+
.pipe((0, operators_1.timeout)({
|
|
333
|
+
each: this.DEFAULT_TIMEOUT,
|
|
334
|
+
with: () => {
|
|
335
|
+
msaLogger.error('RPCInterceptor timeout 발생', { traceId: execInterceptor.traceId }, {
|
|
336
|
+
message: this.DEFAULT_TIMEOUT_MESSAGE,
|
|
337
|
+
messagePattern: method,
|
|
338
|
+
durationMs: Date.now() - now,
|
|
339
|
+
reDeliveryCount,
|
|
340
|
+
staticRetryCount,
|
|
341
|
+
});
|
|
342
|
+
abortController.abort();
|
|
343
|
+
return (0, rxjs_1.throwError)(() => new exceptions_1.InternalServerError('TIMEOUT_ERROR', this.DEFAULT_TIMEOUT_MESSAGE));
|
|
344
|
+
},
|
|
345
|
+
}), (0, operators_1.tap)({
|
|
346
|
+
next: async (val) => {
|
|
347
|
+
val.isError = false;
|
|
348
|
+
/** 만약 응답데이터중 isRequeue가 true라면, 다시 재처리 하도록 함 */
|
|
349
|
+
if (val.data && val.data.isRequeue) {
|
|
350
|
+
channel.nack(message, false, true);
|
|
351
|
+
execInterceptor.isMessageAck = true;
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
if (!noAck) {
|
|
355
|
+
execInterceptor.isMessageAck = true;
|
|
356
|
+
channel.ack(message);
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
error: localErrorProcessor,
|
|
360
|
+
}), (0, operators_1.finalize)(() => {
|
|
361
|
+
this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
|
|
362
|
+
const isAborted = abortController === null || abortController === void 0 ? void 0 : abortController.signal.aborted;
|
|
363
|
+
if (context) {
|
|
364
|
+
if (isAborted) {
|
|
365
|
+
msaLogger.debug('RPCInterceptor context end', { traceId: execInterceptor.traceId }, { context: context.requestId });
|
|
366
|
+
}
|
|
367
|
+
functions_1.AbortContext.endContext();
|
|
368
|
+
// Promise 체인이 완전히 완료될 때까지 지연 후 disable
|
|
369
|
+
// setTimeout으로 여러 번 이벤트 루프를 통과시켜서 모든 Promise.then() 체인이 완료되도록 함
|
|
370
|
+
setTimeout(() => {
|
|
371
|
+
setTimeout(() => {
|
|
372
|
+
setTimeout(() => {
|
|
373
|
+
console.log('RPCInterceptor context disable');
|
|
374
|
+
functions_1.AbortContext.disable();
|
|
375
|
+
}, 0);
|
|
376
|
+
}, 0);
|
|
377
|
+
}, 0);
|
|
355
378
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
})
|
|
359
|
-
this.gracefulShutdownService.popActiveInterceptors(execInterceptor);
|
|
360
|
-
setTimeout(() => {
|
|
361
|
-
functions_1.AbortContext.disable();
|
|
362
|
-
abortController = null;
|
|
363
|
-
}, 1000 * 10);
|
|
364
|
-
return rxjs_1.EMPTY;
|
|
365
|
-
})));
|
|
379
|
+
return rxjs_1.EMPTY;
|
|
380
|
+
}));
|
|
381
|
+
});
|
|
366
382
|
}
|
|
367
383
|
};
|
|
368
384
|
exports.RPCInterceptor = RPCInterceptor;
|