From 601a47ccff2a081fe09dca05325d585c81445369 Mon Sep 17 00:00:00 2001 From: Udit Vasu Date: Mon, 6 May 2024 16:06:41 +0530 Subject: [PATCH] Update test --- lib/bridge.js | 4 +++- lib/index.js | 4 ++-- test/unit/browser/missing-api.test.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/bridge.js b/lib/bridge.js index e6e26d90..8530de1e 100644 --- a/lib/bridge.js +++ b/lib/bridge.js @@ -46,7 +46,9 @@ const Flatted = require('flatted'), // boot code starts hereafter __uvm_setTimeout = setTimeout; - try { ${bootCode}; } catch (error) { + try { + ${bootCode}; + } catch (error) { __uvm_setTimeout(() => { throw error; }, 0); } diff --git a/lib/index.js b/lib/index.js index edf1367c..121d4658 100644 --- a/lib/index.js +++ b/lib/index.js @@ -78,7 +78,7 @@ class UniversalVM extends EventEmitter { * }); */ static spawn (options, callback) { - const uvm = new UniversalVM(options, callback); + const uvm = new UniversalVM(); // connect with the bridge uvm.connect(options, callback); @@ -114,7 +114,7 @@ class UniversalVM extends EventEmitter { catch (e) { } // eslint-disable-line no-empty } - isFunction(callback) && callback.call(this, err, this); + isFunction(callback) && callback(err, this); }; // bail out if bridge is connected diff --git a/test/unit/browser/missing-api.test.js b/test/unit/browser/missing-api.test.js index 51edc55f..ba4c6046 100644 --- a/test/unit/browser/missing-api.test.js +++ b/test/unit/browser/missing-api.test.js @@ -18,7 +18,7 @@ it('should error out if required browser APIs are missing', function (done) { uvm.spawn({}, function (err) { expect(err).to.be.an('error').that.has.property('message', - 'uvm: unable to setup communication bridge, missing required APIs'); + 'uvm: unable to spawn worker.\nMissing required APIs'); done(); }); });