@yolo-croket-dev/core 1.7.29 → 1.7.30-slowquery.2
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 +30 -37
- package/package.json +1 -1
|
@@ -213,6 +213,8 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
213
213
|
const errInfo = err.errInfo;
|
|
214
214
|
const duration = Date.now() - now;
|
|
215
215
|
let isAck = false;
|
|
216
|
+
const isTimeoutError = err instanceof Error
|
|
217
|
+
&& (err.name === 'TimeoutError' || (err.message === this.DEFAULT_TIMEOUT_MESSAGE) || err.message === 'TIMEOUT_ERROR');
|
|
216
218
|
/** 파일 객체 처리 */
|
|
217
219
|
(0, functions_1.reWriteFileValue)(arg === null || arg === void 0 ? void 0 : arg.file);
|
|
218
220
|
const abstractAmqpHandlerData = {
|
|
@@ -249,6 +251,22 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
249
251
|
}
|
|
250
252
|
isAck = true;
|
|
251
253
|
}
|
|
254
|
+
else if (isTimeoutError && reDeliveryCount <= 1) {
|
|
255
|
+
// 타임아웃 에러일때 1회 재시도 허용
|
|
256
|
+
msaLogger.debug('타임아웃 에러일때 1회 재시도 허용', { traceId: execInterceptor.traceId }, {
|
|
257
|
+
message: err.message,
|
|
258
|
+
stack: err.stack,
|
|
259
|
+
name: err.name,
|
|
260
|
+
response: err.response,
|
|
261
|
+
messagePattern: method,
|
|
262
|
+
reDeliveryCount,
|
|
263
|
+
staticRetryCount,
|
|
264
|
+
});
|
|
265
|
+
channel.nack(message, false, true);
|
|
266
|
+
message.properties.replyTo = undefined; /** replyTo가 존재하면 sendToQueue가 호출되므로, 삭제해주기 */
|
|
267
|
+
execInterceptor.isMessageAck = true;
|
|
268
|
+
isAck = true;
|
|
269
|
+
}
|
|
252
270
|
if (options && options.maxLengthKeys && options.maxLengthKeys.length) {
|
|
253
271
|
for (const key of options.maxLengthKeys) {
|
|
254
272
|
this.updateMaxLengthArrayShorten(abstractAmqpHandlerData.arg.payload, key);
|
|
@@ -256,6 +274,18 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
256
274
|
}
|
|
257
275
|
const sendMessage = Buffer.from(JSON.stringify(abstractAmqpHandlerData));
|
|
258
276
|
if (!isAck) {
|
|
277
|
+
// 에러 전달
|
|
278
|
+
msaLogger.error('에러 응답 전송 처리', { traceId: execInterceptor.traceId }, {
|
|
279
|
+
error: {
|
|
280
|
+
message: err.message,
|
|
281
|
+
stack: err.stack,
|
|
282
|
+
name: err.name,
|
|
283
|
+
response: err.response,
|
|
284
|
+
reDeliveryCount,
|
|
285
|
+
staticRetryCount,
|
|
286
|
+
},
|
|
287
|
+
messagePattern: method,
|
|
288
|
+
});
|
|
259
289
|
channel.sendToQueue(message.properties.replyTo, sendMessage, { correlationId: message.properties.correlationId });
|
|
260
290
|
}
|
|
261
291
|
const messageContent = message.content.toString();
|
|
@@ -306,43 +336,6 @@ let RPCInterceptor = class RPCInterceptor {
|
|
|
306
336
|
abortController.abort();
|
|
307
337
|
return (0, rxjs_1.throwError)(() => new exceptions_1.InternalServerError('TIMEOUT_ERROR', this.DEFAULT_TIMEOUT_MESSAGE));
|
|
308
338
|
},
|
|
309
|
-
}),
|
|
310
|
-
// eslint-disable-next-line consistent-return
|
|
311
|
-
(0, operators_1.catchError)(async (err) => {
|
|
312
|
-
const isNackMessage = !execInterceptor.isMessageAck;
|
|
313
|
-
// timeout 에러 처리
|
|
314
|
-
const isTimeoutError = err instanceof Error
|
|
315
|
-
&& (err.name === 'TimeoutError' || (err.message === this.DEFAULT_TIMEOUT_MESSAGE) || err.message === 'TIMEOUT_ERROR');
|
|
316
|
-
if (isTimeoutError) {
|
|
317
|
-
msaLogger.error(`[타임 아웃] 메시지 감지, ${isNackMessage ? '재전달' : '재전달하지 않음'}처리`, { traceId: execInterceptor.traceId }, {
|
|
318
|
-
error: {
|
|
319
|
-
message: err.message,
|
|
320
|
-
stack: err.stack,
|
|
321
|
-
name: err.name,
|
|
322
|
-
response: err.response,
|
|
323
|
-
isNackMessage,
|
|
324
|
-
},
|
|
325
|
-
messagePattern: method,
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
else {
|
|
329
|
-
msaLogger.error(`에러 응답 전송 처리, ${isNackMessage ? '재전달' : '재전달하지 않음'}처리`, { traceId: execInterceptor.traceId }, {
|
|
330
|
-
error: {
|
|
331
|
-
message: err.message,
|
|
332
|
-
stack: err.stack,
|
|
333
|
-
name: err.name,
|
|
334
|
-
response: err.response,
|
|
335
|
-
isNackMessage,
|
|
336
|
-
},
|
|
337
|
-
messagePattern: method,
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
if (isNackMessage) {
|
|
341
|
-
channel.nack(message, false, true);
|
|
342
|
-
execInterceptor.isMessageAck = true;
|
|
343
|
-
message.properties.replyTo = undefined; /** replyTo가 존재하면 sendToQueue가 호출되므로, 삭제해주기 */
|
|
344
|
-
}
|
|
345
|
-
return new rxjs_1.Observable();
|
|
346
339
|
}), (0, operators_1.tap)({
|
|
347
340
|
next: async (val) => {
|
|
348
341
|
val.isError = false;
|