@@ -358,22 +358,24 @@ var ProcLogic = function() {
358358 var countSigId = proc . fullInfo . outcounts &&
359359 proc . fullInfo . outcounts [ funcOuts [ i ] ] ? proc . fullInfo . outcounts [ funcOuts [ i ] ] : undefined ;
360360 if ( countSigId ) {
361- var count = outValues [ i ] . data ? outValues [ i ] . data . length : 1 ;
361+ var count = outValues [ i ] . data ? outValues [ i ] . data . length : 1 ;
362362 var sigId = countSigId . split ( ":" ) [ 1 ] ;
363363
364364 //onsole.log("FUNC OUTS", funcOuts);
365365 //onsole.log("EMITTING COUNT SIG", sigId);
366366 //onsole.log("IN COUNTS", proc.fullInfo.incounts);
367367 //onsole.log("OUT COUNTS", proc.fullInfo.outcounts);
368368 var sigV = { "_id" : + sigId , "count" : count , "control" : "count" , data : [ { } ] } ;
369- if ( ! proc . fullInfo . ordering ) {
370- proc . engine . emitSignals ( [ sigV ] ) ;
371- } else {
372- // TODO: test thouroughly if ordering works correctly with output "count" signals
373- function Arg ( ) { } // we need an Array-like object
374- Arg . prototype = Object . create ( Array . prototype ) ;
375- proc . emitStash [ firingId ] = new Arg ;
376- proc . emitStash [ firingId ] . push ( sigV ) ;
369+ if ( count > 0 ) { // 0 can happen if process returns an empty "data" array
370+ if ( ! proc . fullInfo . ordering ) {
371+ proc . engine . emitSignals ( [ sigV ] ) ;
372+ } else {
373+ // TODO: test thouroughly if ordering works correctly with output "count" signals
374+ function Arg ( ) { } // we need an Array-like object
375+ Arg . prototype = Object . create ( Array . prototype ) ;
376+ proc . emitStash [ firingId ] = new Arg ;
377+ proc . emitStash [ firingId ] . push ( sigV ) ;
378+ }
377379 }
378380 }
379381 }
0 commit comments