Skip to content

Commit

Permalink
Additional logs and tweak to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonk000 committed Aug 27, 2016
1 parent 1f65c9c commit 9e336a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ let Service = function Service (Transports, config) {

function go (data) {
// Handle both callbacks and promises here.
// It is expected that the CALLER only calls the callback OR
// returns a promise. If they do both, there will be two callbacks
let callbackHandler = function (err, response) {
if (err) return cb(err)
return finish(response)
Expand All @@ -116,7 +118,6 @@ let Service = function Service (Transports, config) {
let response = _tmp.fn(data, callbackHandler)

if (response && typeof response.then === 'function') {
callbackHandler = null
return response.then(finish, cb)
// if an exception was thrown from finish(), let it bubble up
// as an unhandled rejection, rather than also call cb()
Expand Down
8 changes: 4 additions & 4 deletions test/z-integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ const Transports = require('../src/transports');

describe("Integrations", function () {
it("does not double call when callback throws", function (done) {
var transport = new Transports.Local();
var service = new Service(transport);
var client = new Client({ s: transport });
const transport = new Transports.Local();
const service = new Service(transport);
const client = new Client({ s: transport });

let countCalled = 0

Expand All @@ -32,7 +32,7 @@ describe("Integrations", function () {
switch (countCalled) {
case 0: throw Error('did not get called at all')
case 1: return done()
case 2: throw Error('called multiple times')
default: throw Error('called multiple times')
}
}, 100)
});
Expand Down

0 comments on commit 9e336a6

Please sign in to comment.