Skip to content

Commit

Permalink
add comments and reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Chen committed Jun 22, 2019
1 parent f8d4a15 commit 5309534
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions dev/src/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,22 +523,27 @@ abstract class Watch {
this.currentStream = backendStream;
this.currentStream!.on('data', (proto: api.IListenResponse) => {
this.onData(proto);
}).on('error', err => {
this.maybeReopenStream(err);
});
this.currentStream!.on('end', () => {
const err = new GrpcError('Stream ended unexpectedly');
err.code = GRPC_STATUS_CODE.UNKNOWN;
this.maybeReopenStream(err);
});
})
.on('error', err => {
this.maybeReopenStream(err);
})
.on('end', () => {
const err = new GrpcError('Stream ended unexpectedly');
err.code = GRPC_STATUS_CODE.UNKNOWN;
this.maybeReopenStream(err);
});
this.currentStream!.resume();
});
})
.catch(err => {
this.closeStream(err);
});
}

/**
* Handles 'data' events and closes the stream if the response type is
* invalid.
* @private
*/
private onData(proto: api.IListenResponse): void {
if (proto.targetChange) {
logger('Watch.onSnapshot', this.requestTag, 'Processing target change');
Expand Down

0 comments on commit 5309534

Please sign in to comment.