Skip to content

Commit

Permalink
fix: use callback for non-transmitted items
Browse files Browse the repository at this point in the history
  • Loading branch information
waltjones committed Jun 28, 2019
1 parent e60cab0 commit a41ac93
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Queue.prototype.addItem = function(item, callback, originalError, originalItem)
this._maybeLog(item, originalError);
this.removePendingItem(originalItem);
if (!this.options.transmit) {
callback(new Error('Transmit disabled'));
return;
}
this.pendingRequests.push(item);
Expand Down
4 changes: 3 additions & 1 deletion test/queue.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,9 @@ describe('addItem', function() {
var queue = new Queue(rateLimiter, api, logger, options);
var makeApiRequestStub = sinon.stub(queue, '_makeApiRequest');

queue.addItem({mykey: 'myvalue'});
queue.addItem({mykey: 'myvalue'}, function(err) {
expect(err.message).to.eql('Transmit disabled');
});

expect(makeApiRequestStub.called).to.eql(0);

Expand Down

0 comments on commit a41ac93

Please sign in to comment.