Skip to content

Commit cb58fbc

Browse files
George Kampitakisgkampitakis
authored andcommitted
fix: use GRPC_NODE_USE_ALTERNATIVE_RESOLVER for enabling new alternative resolver
1 parent 7f27b32 commit cb58fbc

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

packages/grpc-js/src/environment.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Copyright 2024 gRPC authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
export const GRPC_NODE_USE_ALTERNATIVE_RESOLVER =
19+
(process.env.GRPC_NODE_USE_ALTERNATIVE_RESOLVER ?? 'false') === 'true';

packages/grpc-js/src/resolver-dns.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import { GrpcUri, uriToString, splitHostPort } from './uri-parser';
3232
import { isIPv6, isIPv4 } from 'net';
3333
import { ChannelOptions } from './channel-options';
3434
import { BackoffOptions, BackoffTimeout } from './backoff-timeout';
35+
import { GRPC_NODE_USE_ALTERNATIVE_RESOLVER } from './environment';
3536

3637
const TRACER_NAME = 'dns_resolver';
3738

@@ -44,8 +45,7 @@ function trace(text: string): void {
4445
*/
4546
export const DEFAULT_PORT = 443;
4647

47-
const DEFAULT_MIN_TIME_BETWEEN_RESOLUTIONS_MS = 30_000,
48-
DNS_RESOLUTION_ENV = 'GRPC_DNS_RESOLVER_TODO';
48+
const DEFAULT_MIN_TIME_BETWEEN_RESOLUTIONS_MS = 30_000;
4949

5050
/**
5151
* Resolver implementation that handles DNS names and IP addresses.
@@ -296,7 +296,7 @@ class DnsResolver implements Resolver {
296296
}
297297

298298
private async lookup(hostname: string): Promise<TcpSubchannelAddress[]> {
299-
if (process.env[DNS_RESOLUTION_ENV] === 'true') {
299+
if (GRPC_NODE_USE_ALTERNATIVE_RESOLVER) {
300300
const records = await Promise.allSettled([
301301
this.independentResolver.resolve4(hostname),
302302
this.independentResolver.resolve6(hostname),
@@ -323,7 +323,7 @@ class DnsResolver implements Resolver {
323323
}
324324

325325
private async resolveTxt(hostname: string): Promise<string[][]> {
326-
if (process.env[DNS_RESOLUTION_ENV] === 'true') {
326+
if (GRPC_NODE_USE_ALTERNATIVE_RESOLVER) {
327327
return this.independentResolver.resolveTxt(hostname);
328328
}
329329

0 commit comments

Comments
 (0)