mirror of https://github.com/grpc/grpc-node.git
				
				
				
			Merge pull request #768 from murgatroid99/grpc-js_deadline_filter_promise_finish
grpc-js: deadline filter: reject promise if call ends
This commit is contained in:
		
						commit
						8704950a5c
					
				|  | @ -60,9 +60,16 @@ export class DeadlineFilter extends BaseFilter implements Filter { | |||
|                    resolve(metadata); | ||||
|                    this.channel.removeListener( | ||||
|                        'connectivityStateChanged', handleStateChange); | ||||
|                    this.callStream.removeListener('status', handleStatus); | ||||
|                  } | ||||
|                }; | ||||
|                const handleStatus = () => { | ||||
|                  reject(new Error('Call ended')); | ||||
|                  this.channel.removeListener( | ||||
|                      'connectivityStateChanged', handleStateChange); | ||||
|                }; | ||||
|                this.channel.on('connectivityStateChanged', handleStateChange); | ||||
|                this.callStream.once('status', handleStatus); | ||||
|              } | ||||
|            }) | ||||
|         .then((finalMetadata: Metadata) => { | ||||
|  |  | |||
|  | @ -46,6 +46,7 @@ export class Http2SubChannel extends EventEmitter implements SubChannel { | |||
|       userAgent: string, channelArgs: Partial<ChannelOptions>) { | ||||
|     super(); | ||||
|     this.session = http2.connect(target, connectionOptions); | ||||
|     this.session.unref(); | ||||
|     this.session.on('connect', () => { | ||||
|       this.emit('connect'); | ||||
|     }); | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue