Compare View
Commits (2)
Changes
Showing 2 changed files Side-by-side Diff
gateway/resend-delay.js
... | ... | @@ -29,13 +29,13 @@ function _resend(task, request) { |
29 | 29 | function cancel(_task) { |
30 | 30 | config && config.auto_resend && config.auto_resend.debug && logger.verbose('SDK-RESEND-DELAY: Preparing', {task: _task, typeof_task: typeof _task}); |
31 | 31 | |
32 | - const trx_id = ( typeof _task === 'string' ) ? _task : _task.trx_id; | |
32 | + const trx_id = ( typeof _task === 'object' ) ? _task.trx_id : _task; | |
33 | 33 | if (!trx_id) { |
34 | 34 | logger.warn('SDK-RESEND-DELAY: Skipping cancel because of undefined trx_id'); |
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | - const oldHandler = resendHandlers.get(trx_id); | |
38 | + const oldHandler = resendHandlers.get('TASK_' + trx_id); | |
39 | 39 | if (!oldHandler) { |
40 | 40 | config && config.auto_resend && config.auto_resend.debug && logger.verbose('SDK-RESEND-DELAY: Skipping cancel because of undefined oldHandler', {trx_id: trx_id}); |
41 | 41 | return; |
... | ... | @@ -45,7 +45,7 @@ function cancel(_task) { |
45 | 45 | logger.verbose('SDK-RESEND-DELAY: Canceling task', {trx_id: task.trx_id, destination: task.destination, product: task.product, remote_product: task.remote_product}); |
46 | 46 | |
47 | 47 | if (oldHandler.handler) { clearTimeout(oldHandler.handler); } |
48 | - resendHandlers.del(trx_id); | |
48 | + resendHandlers.del('TASK_' + trx_id); | |
49 | 49 | } |
50 | 50 | |
51 | 51 | function register(task, request) { |
... | ... | @@ -59,7 +59,7 @@ function register(task, request) { |
59 | 59 | } |
60 | 60 | |
61 | 61 | let retry = config.auto_resend.max_retry; |
62 | - const oldHandler = resendHandlers.get(task.trx_id); | |
62 | + const oldHandler = resendHandlers.get('TASK_' + task.trx_id); | |
63 | 63 | if (oldHandler) { |
64 | 64 | retry = oldHandler.retry - 1; |
65 | 65 | cancel(task); |
... | ... | @@ -81,7 +81,7 @@ function register(task, request) { |
81 | 81 | retry: retry |
82 | 82 | } |
83 | 83 | |
84 | - resendHandlers.set(task.trx_id, handlerData); | |
84 | + resendHandlers.set('TASK_' + task.trx_id, handlerData); | |
85 | 85 | } |
86 | 86 | |
87 | 87 | setInterval( |