mirror of https://github.com/grpc/grpc-node.git
				
				
				
			Merge pull request #1413 from murgatroid99/grpc-js_pick_first_reconnect_fix
grpc-js: Fix pick_first handling of IDLE subchannels.
This commit is contained in:
		
						commit
						69d4116057
					
				|  | @ -1,6 +1,6 @@ | |||
| { | ||||
|   "name": "@grpc/grpc-js", | ||||
|   "version": "1.0.3", | ||||
|   "version": "1.0.4", | ||||
|   "description": "gRPC Library for Node - pure JS implementation", | ||||
|   "homepage": "https://grpc.io/", | ||||
|   "repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js", | ||||
|  |  | |||
|  | @ -130,7 +130,6 @@ export class PickFirstLoadBalancer implements LoadBalancer { | |||
|    *     this load balancer's owner. | ||||
|    */ | ||||
|   constructor(private channelControlHelper: ChannelControlHelper) { | ||||
|     this.updateState(ConnectivityState.IDLE, new QueuePicker(this)); | ||||
|     this.subchannelStateCounts = { | ||||
|       [ConnectivityState.CONNECTING]: 0, | ||||
|       [ConnectivityState.IDLE]: 0, | ||||
|  | @ -168,6 +167,8 @@ export class PickFirstLoadBalancer implements LoadBalancer { | |||
|            * basic IDLE state where there is no subchannel list to avoid | ||||
|            * holding unused resources */ | ||||
|           this.resetSubchannelList(); | ||||
|           this.updateState(ConnectivityState.IDLE, new QueuePicker(this)); | ||||
|           return; | ||||
|         } | ||||
|         if (this.currentPick === null) { | ||||
|           if (this.triedAllSubchannels) { | ||||
|  |  | |||
|  | @ -95,7 +95,6 @@ export class RoundRobinLoadBalancer implements LoadBalancer { | |||
|   private currentReadyPicker: RoundRobinPicker | null = null; | ||||
| 
 | ||||
|   constructor(private channelControlHelper: ChannelControlHelper) { | ||||
|     this.updateState(ConnectivityState.IDLE, new QueuePicker(this)); | ||||
|     this.subchannelStateCounts = { | ||||
|       [ConnectivityState.CONNECTING]: 0, | ||||
|       [ConnectivityState.IDLE]: 0, | ||||
|  |  | |||
|  | @ -69,3 +69,26 @@ describe('Client', () => { | |||
|     }, deadline - Date.now()); | ||||
|   }); | ||||
| }); | ||||
| 
 | ||||
| describe('Client without a server', () => { | ||||
|   let client: Client; | ||||
|   before(() => { | ||||
|     // Arbitrary target that should not have a running server
 | ||||
|     client = new Client('localhost:12345', clientInsecureCreds); | ||||
|   }); | ||||
|   after(() => { | ||||
|     client.close(); | ||||
|   }); | ||||
|   it('should fail multiple calls to the nonexistent server', done => { | ||||
|     // Regression test for https://github.com/grpc/grpc-node/issues/1411
 | ||||
|     client.makeUnaryRequest('/service/method', x => x, x => x, Buffer.from([]), (error, value) => { | ||||
|       assert(error); | ||||
|       assert.strictEqual(error?.code, grpc.status.UNAVAILABLE); | ||||
|       client.makeUnaryRequest('/service/method', x => x, x => x, Buffer.from([]), (error, value) => { | ||||
|         assert(error); | ||||
|         assert.strictEqual(error?.code, grpc.status.UNAVAILABLE); | ||||
|         done(); | ||||
|       }); | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
		Loading…
	
		Reference in New Issue