From d932d3db56ae06e48a0a03af934c3232c8da89f5 Mon Sep 17 00:00:00 2001 From: Ross Johnson Date: Sat, 6 Jul 2013 10:05:44 -0500 Subject: [PATCH 1/3] Fix crashing fetch tests by setting keepalive = false When keepalive = true (the default), additional IDLE requests are sent to the IMAP server. The mock IMAP servers in the tests are not set up to respond to the IDLE request. --- test/test-connection-fetch-dup.js | 3 ++- test/test-connection-fetch-frag.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test-connection-fetch-dup.js b/test/test-connection-fetch-dup.js index ff54abb..9344d85 100644 --- a/test/test-connection-fetch-dup.js +++ b/test/test-connection-fetch-dup.js @@ -53,7 +53,8 @@ srv.listen(0, '127.0.0.1', function() { user: 'foo', password: 'bar', host: '127.0.0.1', - port: port + port: port, + keepalive: false }); imap.on('ready', function() { imap.openBox('INBOX', true, function() { diff --git a/test/test-connection-fetch-frag.js b/test/test-connection-fetch-frag.js index 46341ea..b05a15a 100644 --- a/test/test-connection-fetch-frag.js +++ b/test/test-connection-fetch-frag.js @@ -53,7 +53,8 @@ srv.listen(0, '127.0.0.1', function() { user: 'foo', password: 'bar', host: '127.0.0.1', - port: port + port: port, + keepalive: false }); imap.on('ready', function() { imap.openBox('INBOX', true, function() { From 96af8f4a8e256be89a25e51065449fe5d4d3f514 Mon Sep 17 00:00:00 2001 From: Ross Johnson Date: Sat, 6 Jul 2013 10:16:51 -0500 Subject: [PATCH 2/3] Fix fetch crash when all parts come back immediately Resolves "TypeError: Cannot set property 'ended' of undefined" if bodies are sent immediately and no msg is added to the fetchCache. --- lib/Connection.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Connection.js b/lib/Connection.js index 537f6be..084ae7c 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -1115,7 +1115,7 @@ Connection.prototype._resUntagged = function(info) { if (toget.length === 0) { process.nextTick(function() { - msg.ended = true; + if (msg) msg.ended = true; msgEmitter.emit('attributes', attrs); msgEmitter.emit('end'); }); From c1b1a0b2d1c946f7b8e76a25d205e3293dabdb03 Mon Sep 17 00:00:00 2001 From: Ross Johnson Date: Sat, 6 Jul 2013 12:43:45 -0500 Subject: [PATCH 3/3] Fix formatting --- lib/Connection.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Connection.js b/lib/Connection.js index 084ae7c..9211dc9 100644 --- a/lib/Connection.js +++ b/lib/Connection.js @@ -1115,7 +1115,8 @@ Connection.prototype._resUntagged = function(info) { if (toget.length === 0) { process.nextTick(function() { - if (msg) msg.ended = true; + if (msg) + msg.ended = true; msgEmitter.emit('attributes', attrs); msgEmitter.emit('end'); });