File tree Expand file tree Collapse file tree 1 file changed +13
-5
lines changed
Expand file tree Collapse file tree 1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,12 @@ exports.key = 'events';
3434exports . callbackQueue = [ ] ;
3535
3636exports . add = function ( job , callback ) {
37- if ( job . id ) exports . jobs [ job . id ] = job ;
37+ if ( job . id ) {
38+ if ( ! exports . jobs [ job . id ] )
39+ exports . jobs [ job . id ] = [ ] ;
40+
41+ exports . jobs [ job . id ] . push ( job ) ;
42+ }
3843// if (!exports.subscribed) exports.subscribe();
3944 if ( ! exports . subscribeStarted ) exports . subscribe ( ) ;
4045 if ( ! exports . subscribed ) {
@@ -95,10 +100,13 @@ exports.onMessage = function( channel, msg ) {
95100 msg = JSON . parse ( msg ) ;
96101
97102 // map to Job when in-process
98- var job = exports . jobs [ msg . id ] ;
99- if ( job ) {
100- job . emit . apply ( job , msg . args ) ;
101- if ( [ 'complete' , 'failed' ] . indexOf ( msg . event ) !== - 1 ) exports . remove ( job ) ;
103+ var jobs = exports . jobs [ msg . id ] ;
104+ if ( jobs && jobs . length > 0 ) {
105+ for ( var i = 0 ; i < jobs . length ; i ++ ) {
106+ var job = jobs [ i ] ;
107+ job . emit . apply ( job , msg . args ) ;
108+ if ( [ 'complete' , 'failed' ] . indexOf ( msg . event ) !== - 1 ) exports . remove ( job ) ;
109+ }
102110 }
103111 // emit args on Queues
104112 msg . args [ 0 ] = 'job ' + msg . args [ 0 ] ;
You can’t perform that action at this time.
0 commit comments