Skip to content

Commit

Permalink
Merge pull request #2618 from murgatroid99/grpc-js_uds_return_once
Browse files Browse the repository at this point in the history
grpc-js: Return the result from the UDS resolver only once
  • Loading branch information
murgatroid99 committed Nov 16, 2023
2 parents 056738f + 736d6df commit 667bae6
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/grpc-js/src/resolver-uds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ChannelOptions } from './channel-options';

class UdsResolver implements Resolver {
private addresses: SubchannelAddress[] = [];
private hasReturnedResult = false;
constructor(
target: GrpcUri,
private listener: ResolverListener,
Expand All @@ -35,14 +36,17 @@ class UdsResolver implements Resolver {
this.addresses = [{ path }];
}
updateResolution(): void {
process.nextTick(
this.listener.onSuccessfulResolution,
this.addresses,
null,
null,
null,
{}
);
if (!this.hasReturnedResult) {
this.hasReturnedResult = true;
process.nextTick(
this.listener.onSuccessfulResolution,
this.addresses,
null,
null,
null,
{}
);
}
}

destroy() {
Expand Down

0 comments on commit 667bae6

Please sign in to comment.