From b751478f02a94bb94f530b5eb999262b4a8ef208 Mon Sep 17 00:00:00 2001 From: Gil Pedersen Date: Wed, 23 Oct 2024 16:15:46 +0200 Subject: [PATCH] Fix background() missing return option support --- lib/index.js | 2 +- test/index.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 7854ba1..357d850 100755 --- a/lib/index.js +++ b/lib/index.js @@ -78,7 +78,7 @@ exports.background = async function (operation, action = 'rethrow', types = 'sys } } catch (err) { - exports[action](err, types, options); + return exports[action](err, types, options); } }; diff --git a/test/index.js b/test/index.js index 3f28ea4..b617e98 100755 --- a/test/index.js +++ b/test/index.js @@ -427,6 +427,19 @@ describe('Bounce', () => { Bounce.background(test, 'rethrow', 'system'); }); + + it('supports the return option', async () => { + + const test = async () => { + + await Hoek.wait(1); + throw new SyntaxError('Something'); + }; + + const res = await Bounce.background(test(), 'rethrow', 'system', { return: true }); + expect(res).to.exist(); + expect(res).to.be.an.error(SyntaxError); + }); }); describe('isBoom()', () => {