From a047dcf4e52df75f76036b17646e0407dbd83c02 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Fri, 6 Nov 2020 13:03:22 -0400 Subject: [PATCH] avoid duplicate heeaders sent by handleError() --- src/routes.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/routes.js b/src/routes.js index d17990f2..741c59da 100644 --- a/src/routes.js +++ b/src/routes.js @@ -655,15 +655,20 @@ module.exports = async ( const user = require('../services/gunDB/Mediator').getUser() const SEA = require('../services/gunDB/Mediator').mySEA - lightning.exportAllChannelBackups({}, (err, channelBackups) => { - if (err) { - return handleError(res, err) - } - GunActions.saveChannelsBackup( - JSON.stringify(channelBackups), - user, - SEA - ) + await Common.Utils.makePromise((res, rej) => { + lightning.exportAllChannelBackups({}, (err, channelBackups) => { + if (err) { + return rej(new Error(err.details)) + } + + res( + GunActions.saveChannelsBackup( + JSON.stringify(channelBackups), + user, + SEA + ) + ) + }) }) // Send an event to update lightning's status