From dda7bacca7d3424006498ffd2df1511020288b21 Mon Sep 17 00:00:00 2001 From: Sky Young Date: Tue, 22 May 2018 14:36:33 -0700 Subject: [PATCH] Don't send if headers have already been sent --- lib/common.js | 9 ++++++--- package.json | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/common.js b/lib/common.js index 70e5954..d11ad79 100644 --- a/lib/common.js +++ b/lib/common.js @@ -16,13 +16,16 @@ Common.prototype.notReady = function (err, res, p) { Common.prototype.handleErrors = function (err, res) { if (err) { if (err.code) { - res.status(400).send(err.message + '. Code:' + err.code); + if (!res.headerSent) + res.status(400).send(err.message + '. Code:' + err.code); } else { this.log.error(err.stack); - res.status(503).send(err.message); + if (!res.headerSent) + res.status(503).send(err.message); } } else { - res.status(404).send('Not found'); + if (!res.headerSent) + res.status(404).send('Not found'); } }; diff --git a/package.json b/package.json index 1b2f72c..295453a 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "flosight-api", "description": "A Florincoin blockchain REST and web socket API service for Flocore Node.", - "version": "5.0.0-beta.68", + "version": "5.0.0-beta.69", "repository": "git://github.com/bitpay/flosight-api.git", "bugs": { "url": "https://github.com/bitpay/flosight-api/issues"