From 7a9e83d5a1ca60a87df477467c15c981ef8ed098 Mon Sep 17 00:00:00 2001 From: John Dierks Date: Fri, 22 Apr 2016 22:23:04 -0700 Subject: [PATCH 1/4] fixed issue where message body is not json caused process to crash --- dist/sqs-queue-parallel.js | 8 +++++++- src/sqs-queue-parallel.coffee | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/dist/sqs-queue-parallel.js b/dist/sqs-queue-parallel.js index 2663227..c9568b0 100644 --- a/dist/sqs-queue-parallel.js +++ b/dist/sqs-queue-parallel.js @@ -74,9 +74,15 @@ console.log("SqsQueueParallel " + self.config.name + "[" + index + "]: " + queue.Messages.length + " new messages"); } return async.eachSeries(queue.Messages, function(message, next) { + var data; + try { + data = JSON.parse(message.Body); + } catch (_error) { + data = message.Body; + } return self.emit("message", { type: 'message', - data: JSON.parse(message.Body) || message.Body, + data: data, message: message, metadata: queue.ResponseMetadata, url: self.url, diff --git a/src/sqs-queue-parallel.coffee b/src/sqs-queue-parallel.coffee index 3ebdb1b..448bc86 100644 --- a/src/sqs-queue-parallel.coffee +++ b/src/sqs-queue-parallel.coffee @@ -43,9 +43,15 @@ module.exports = class SqsQueueParallel extends events.EventEmitter return next null unless queue.Messages?[0] console.log "SqsQueueParallel #{ self.config.name }[#{ index }]: #{ queue.Messages.length } new messages" if self.config.debug async.eachSeries queue.Messages, (message, next) -> + + try + data = JSON.parse(message.Body) + catch + data = message.Body + self.emit "message", type: 'message' - data: JSON.parse(message.Body) or message.Body + data: data message: message metadata: queue.ResponseMetadata url: self.url From 905debdddd2ef9a4fac3f35829e0658fe8a7ddee Mon Sep 17 00:00:00 2001 From: John Dierks Date: Fri, 22 Apr 2016 22:28:19 -0700 Subject: [PATCH 2/4] removed extra new lines --- src/sqs-queue-parallel.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/sqs-queue-parallel.coffee b/src/sqs-queue-parallel.coffee index 448bc86..6204e5e 100644 --- a/src/sqs-queue-parallel.coffee +++ b/src/sqs-queue-parallel.coffee @@ -43,12 +43,10 @@ module.exports = class SqsQueueParallel extends events.EventEmitter return next null unless queue.Messages?[0] console.log "SqsQueueParallel #{ self.config.name }[#{ index }]: #{ queue.Messages.length } new messages" if self.config.debug async.eachSeries queue.Messages, (message, next) -> - try data = JSON.parse(message.Body) catch data = message.Body - self.emit "message", type: 'message' data: data From 01612813b432b0e123504e8d0fe9e39dc320bf2d Mon Sep 17 00:00:00 2001 From: John Dierks Date: Fri, 22 Apr 2016 22:29:29 -0700 Subject: [PATCH 3/4] updated package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 64afc39..390852d 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "dist/sqs-queue-parallel", "homepage": "https://github.com/bigluck/sqs-queue-parallel", "author": "Luca Bigon", - "version": "0.1.6", + "version": "0.1.7", "license": "MIT", "licenses": [ { From f20b5f28d8070a388de5c2a7a6e3ab0b94093f64 Mon Sep 17 00:00:00 2001 From: John Dierks Date: Fri, 22 Apr 2016 22:39:50 -0700 Subject: [PATCH 4/4] updated formatting --- dist/sqs-queue-parallel.js | 2 +- src/sqs-queue-parallel.coffee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/sqs-queue-parallel.js b/dist/sqs-queue-parallel.js index c9568b0..57fb505 100644 --- a/dist/sqs-queue-parallel.js +++ b/dist/sqs-queue-parallel.js @@ -1,5 +1,5 @@ /** - * sqs-queue-parallel 0.1.6 + * sqs-queue-parallel 0.1.7 * Create a poll of Amazon SQS queue watchers and each one can receive 1+ messages * * Available under MIT license diff --git a/src/sqs-queue-parallel.coffee b/src/sqs-queue-parallel.coffee index 6204e5e..5dcbbf9 100644 --- a/src/sqs-queue-parallel.coffee +++ b/src/sqs-queue-parallel.coffee @@ -44,7 +44,7 @@ module.exports = class SqsQueueParallel extends events.EventEmitter console.log "SqsQueueParallel #{ self.config.name }[#{ index }]: #{ queue.Messages.length } new messages" if self.config.debug async.eachSeries queue.Messages, (message, next) -> try - data = JSON.parse(message.Body) + data = JSON.parse(message.Body) catch data = message.Body self.emit "message",