@yolo-croket-dev/core 1.7.25 → 1.7.26-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.
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AmqpHandler = exports.HttpExceptionCustom = void 0;
4
4
  const common_1 = require("@nestjs/common");
5
5
  const rxjs_1 = require("rxjs");
6
+ const operators_1 = require("rxjs/operators");
6
7
  const msa_logger_1 = require("@yolo-croket-dev/msa-logger");
7
8
  const _1 = require(".");
9
+ const DEFAULT_TIMEOUT = 1000; // 29분 타임아웃
10
+ const DEFAULT_TIMEOUT_MESSAGE = '요청이 타임아웃되었습니다.';
8
11
  const msaLogger = new msa_logger_1.MsaLogger(msa_logger_1.ServerTypeEnum.SERVICE);
9
12
  class HttpExceptionCustom extends common_1.HttpException {
10
13
  constructor(response, status, subMessage, errInfo) {
@@ -19,7 +22,7 @@ async function AmqpHandler(client, messagePattern, payload) {
19
22
  var _a, _b, _c;
20
23
  let data;
21
24
  try {
22
- data = await (0, rxjs_1.lastValueFrom)(client.send(messagePattern, payload).pipe());
25
+ data = await (0, rxjs_1.lastValueFrom)(client.send(messagePattern, payload).pipe((0, operators_1.timeout)(DEFAULT_TIMEOUT)));
23
26
  if (data.isError) {
24
27
  const status = data.status || 500;
25
28
  const subMessage = data.subMessage;
@@ -51,6 +54,12 @@ async function AmqpHandler(client, messagePattern, payload) {
51
54
  message: `${messagePattern} 해당 메시지 패턴은 존재하지 않습니다.`,
52
55
  });
53
56
  }
57
+ else if (err instanceof rxjs_1.TimeoutError || err.message === DEFAULT_TIMEOUT_MESSAGE) {
58
+ throw new HttpExceptionCustom(DEFAULT_TIMEOUT_MESSAGE, 500, DEFAULT_TIMEOUT_MESSAGE, {
59
+ type: 'TIMEOUT_ERROR',
60
+ message: DEFAULT_TIMEOUT_MESSAGE,
61
+ });
62
+ }
54
63
  else {
55
64
  msaLogger.error('AMQP_HANDLER_ERROR', { traceId: ((_c = payload === null || payload === void 0 ? void 0 : payload.param) === null || _c === void 0 ? void 0 : _c.traceId) || '-' }, { err });
56
65
  throw err;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.7.25",
3
+ "version": "1.7.26-slowquery.1",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",