From d0566ef471b0ce7d685b107079b54c888d007c2b Mon Sep 17 00:00:00 2001 From: Jack Williams Date: Mon, 29 Jan 2018 13:53:49 +0000 Subject: [PATCH 1/2] fix(request): set message expiration to match given timeout --- lib/Request.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/Request.js b/lib/Request.js index 9f0e510..c992354 100644 --- a/lib/Request.js +++ b/lib/Request.js @@ -107,6 +107,12 @@ class Request extends CallableInstance { message.priority = parsedOptions.priority } + let timeout = 30000 + let givenTimeout = Number(parsedOptions.timeout) + if (!isNaN(givenTimeout)) timeout = givenTimeout + + if (timeout) message.expiration = timeout + let parsedData let eventData = data @@ -136,10 +142,6 @@ class Request extends CallableInstance { this._emitter.emit('sent', event) - let timeout = 30000 - let givenTimeout = Number(parsedOptions.timeout) - if (!isNaN(givenTimeout)) timeout = givenTimeout - if (timeout) { this._setTimer(messageId, timeout, event) } From 62b8048ca1fa1e8e19402cf6e7c5f73d0916f854 Mon Sep 17 00:00:00 2001 From: Jack Williams Date: Mon, 29 Jan 2018 13:59:13 +0000 Subject: [PATCH 2/2] tests(requests): add test stub for expirations following timeouts We can't actually add a test for this yet. There would need to be an existing endpoint queue which was not _active_, but we currently have no way to do that. There's a PR for pausing in the pipeline (jpwilliams/remit#73), but until then we can't really test it. --- test/request.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/request.test.js b/test/request.test.js index 853a37c..03f98e6 100644 --- a/test/request.test.js +++ b/test/request.test.js @@ -142,6 +142,7 @@ describe('Request', function () { }) it('should return fallback if timing out and fallback set') + it('should expire from queue after same time as timeout') it('should send NULL if given unparsable data') }) })