Skip to content

Commit

Permalink
grpc-js: Return the result from the UDS resolver only once
Browse files Browse the repository at this point in the history
  • Loading branch information
murgatroid99 committed Nov 16, 2023
1 parent 056738f commit 736d6df
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 736d6df

Please sign in to comment.