fixed issue with hanging promise on first appended token
This commit is contained in:
		
							parent
							
								
									dcdd4f8142
								
							
						
					
					
						commit
						2a7121f79f
					
				
							
								
								
									
										16
									
								
								wsclient.js
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								wsclient.js
									
									
									
									
									
								
							| @ -445,12 +445,15 @@ function run(copts) { | |||||||
|       clearTimeout(timeoutId); |       clearTimeout(timeoutId); | ||||||
|       wstunneler = null; |       wstunneler = null; | ||||||
|       clientHandlers.closeAll(); |       clientHandlers.closeAll(); | ||||||
|  | 
 | ||||||
|  |       var error = new Error('websocket connection closed before response'); | ||||||
|  |       error.code = 'E_CONN_CLOSED'; | ||||||
|       Object.keys(pendingCommands).forEach(function (id) { |       Object.keys(pendingCommands).forEach(function (id) { | ||||||
|         pendingCommands[id]({ |         pendingCommands[id](error); | ||||||
|           message: 'websocket connection closed before response' |  | ||||||
|         , code: 'E_CONN_CLOSED' |  | ||||||
|         }); |  | ||||||
|       }); |       }); | ||||||
|  |       if (connCallback) { | ||||||
|  |         connCallback(error); | ||||||
|  |       } | ||||||
| 
 | 
 | ||||||
|       if (!authenticated) { |       if (!authenticated) { | ||||||
|         console.info('[close] failed on first attempt... check authentication.'); |         console.info('[close] failed on first attempt... check authentication.'); | ||||||
| @ -465,6 +468,9 @@ function run(copts) { | |||||||
|   , onError: function (err) { |   , onError: function (err) { | ||||||
|       console.error("[tunnel error] " + err.message); |       console.error("[tunnel error] " + err.message); | ||||||
|       console.error(err); |       console.error(err); | ||||||
|  |       if (connCallback) { | ||||||
|  |         connCallback(err); | ||||||
|  |       } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|   , sendMessage: function (msg) { |   , sendMessage: function (msg) { | ||||||
| @ -577,7 +583,7 @@ function run(copts) { | |||||||
|       prom.catch(function (err) { |       prom.catch(function (err) { | ||||||
|         console.error('adding token', token, 'failed:', err); |         console.error('adding token', token, 'failed:', err); | ||||||
|         // Most probably an invalid token of some kind, so we don't really want to keep it.
 |         // Most probably an invalid token of some kind, so we don't really want to keep it.
 | ||||||
|         tokens.splice(tokens.indexOf(token)); |         tokens.splice(tokens.indexOf(token), 1); | ||||||
|       }); |       }); | ||||||
| 
 | 
 | ||||||
|       return prom; |       return prom; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user