@@ -100,9 +100,9 @@ export class ServerRMQ extends Server<RmqEvents, RmqStatus> {
100
100
}
101
101
}
102
102
103
- public close ( ) : void {
104
- this . channel && this . channel . close ( ) ;
105
- this . server && this . server . close ( ) ;
103
+ public async close ( ) : Promise < void > {
104
+ this . channel && ( await this . channel . close ( ) ) ;
105
+ this . server && ( await this . server . close ( ) ) ;
106
106
this . pendingEventListeners = [ ] ;
107
107
}
108
108
@@ -135,25 +135,28 @@ export class ServerRMQ extends Server<RmqEvents, RmqStatus> {
135
135
this . pendingEventListeners = [ ] ;
136
136
137
137
const connectFailedEvent = 'connectFailed' ;
138
- this . server ! . once ( connectFailedEvent , ( error : Record < string , unknown > ) => {
139
- this . _status$ . next ( RmqStatus . DISCONNECTED ) ;
140
-
141
- this . logger . error ( CONNECTION_FAILED_MESSAGE ) ;
142
- if ( error ?. err ) {
143
- this . logger . error ( error . err ) ;
144
- }
145
- const isReconnecting = ! ! this . channel ;
146
- if (
147
- maxConnectionAttempts === INFINITE_CONNECTION_ATTEMPTS ||
148
- isReconnecting
149
- ) {
150
- return ;
151
- }
152
- if ( ++ this . connectionAttempts === maxConnectionAttempts ) {
153
- this . close ( ) ;
154
- callback ?.( error . err ?? new Error ( CONNECTION_FAILED_MESSAGE ) ) ;
155
- }
156
- } ) ;
138
+ this . server ! . once (
139
+ connectFailedEvent ,
140
+ async ( error : Record < string , unknown > ) => {
141
+ this . _status$ . next ( RmqStatus . DISCONNECTED ) ;
142
+
143
+ this . logger . error ( CONNECTION_FAILED_MESSAGE ) ;
144
+ if ( error ?. err ) {
145
+ this . logger . error ( error . err ) ;
146
+ }
147
+ const isReconnecting = ! ! this . channel ;
148
+ if (
149
+ maxConnectionAttempts === INFINITE_CONNECTION_ATTEMPTS ||
150
+ isReconnecting
151
+ ) {
152
+ return ;
153
+ }
154
+ if ( ++ this . connectionAttempts === maxConnectionAttempts ) {
155
+ await this . close ( ) ;
156
+ callback ?.( error . err ?? new Error ( CONNECTION_FAILED_MESSAGE ) ) ;
157
+ }
158
+ } ,
159
+ ) ;
157
160
}
158
161
159
162
public createClient < T = any > ( ) : T {
0 commit comments