that.doneProcessing = function(error) {
        var processingCount = Object.keys(processingQueue).length;
        var incomingCount = Object.keys(incomingQueue).length;
        var totalCount = processingCount + incomingCount;

        if (!that.cancelled) {
            if (error) {
                setOffline(true);
                log.error(error);
                that.cancel();
                return;
            }
            that.emit('log', 'done processing');

            if (totalCount > 0) {
                log('new items added, processing immediately');
                setTimeout(function() {
                    processing = false;
                    that.checkToProcess();
                }, opts.retryInterval);
            } else {
                processing = false;
                that.emit('state', 'idle');
            }
        }
    };