From 73b67026c786f9c5cfe4dca7834af1eaa03c03a2 Mon Sep 17 00:00:00 2001 From: James Allen Date: Tue, 25 Mar 2014 23:05:32 +0000 Subject: [PATCH] Only put timeout on response, not whole request --- services/web/TpdsWorker.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/web/TpdsWorker.coffee b/services/web/TpdsWorker.coffee index 9c70c2abeb..481448f313 100644 --- a/services/web/TpdsWorker.coffee +++ b/services/web/TpdsWorker.coffee @@ -45,8 +45,10 @@ processingFuncs = origin = request(options.streamOrigin) cancelled = false + gotResponse = false origin.on 'response', (res) -> return if cancelled + gotResponse = true if 200 <= res.statusCode < 300 dest = request(options) origin.pipe(dest) @@ -63,10 +65,12 @@ processingFuncs = origin.on 'error', (err)-> return if cancelled + gotResponse = true logger.error err:err, options:options, "something went wrong in pipeStreamFrom origin" callback(err) setTimeout () -> + return if gotResponse cancelled = true error = new Error("timeout") logger.error err: error, options: options, "timeout"