Kaynağa Gözat

EAGLESIX-3077: Added code for interrupt as suggested per PR

David Aebersold 11 yıl önce
ebeveyn
işleme
f027344447

+ 3 - 0
lib/pipeline/documentSources/LimitDocumentSource.js

@@ -52,6 +52,9 @@ proto.coalesce = function coalesce(nextSource) {
 proto.getNext = function getNext(callback) {
 	if (!callback) throw new Error(this.getSourceName() + ' #getNext() requires callback');
 
+	if (this.expCtx instanceof Object && this.expCtx.checkForInterrupt && this.expCtx.checkForInterrupt() === false)
+		return callback(new Error("Interrupted"));
+
 	if (++this.count > this.limit) {
 		this.source.dispose();
 		callback(null, DocumentSource.EOF);