File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -115,10 +115,6 @@ class Producer {
115
115
this . #internalClient. on ( 'event.error' , this . #errorCb. bind ( this ) ) ;
116
116
this . #internalClient. on ( 'event.log' , console . log ) ;
117
117
118
- this . #internalClient. on ( 'disconnected' , ( arg ) => {
119
- this . #state = ProducerState . DISCONNECTED ;
120
- } ) ;
121
-
122
118
return new Promise ( ( resolve , reject ) => {
123
119
this . #connectPromiseFunc = { resolve, reject} ;
124
120
console . log ( "Connecting...." ) ;
@@ -127,12 +123,18 @@ class Producer {
127
123
} ) ;
128
124
}
129
125
130
- disconnect ( ) {
126
+ async disconnect ( ) {
131
127
if ( this . #state >= ProducerState . DISCONNECTING ) {
132
128
return ;
133
129
}
134
130
this . #state = ProducerState . DISCONNECTING ;
135
- this . #internalClient. disconnect ( ) ;
131
+ await new Promise ( ( resolve , reject ) => {
132
+ const cb = ( err ) => {
133
+ err ? reject ( err ) : resolve ( ) ;
134
+ this . #state = ProducerState . DISCONNECTED ;
135
+ }
136
+ this . #internalClient. disconnect ( 5000 , cb ) ;
137
+ } ) ;
136
138
}
137
139
138
140
async send ( sendOptions ) {
You can’t perform that action at this time.
0 commit comments