Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc-js-xds: Update @types/node and update code for compatibility (1.9.x) #2860

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/grpc-js-xds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"@types/gulp": "^4.0.6",
"@types/gulp-mocha": "0.0.32",
"@types/mocha": "^5.2.6",
"@types/node": "^13.11.1",
"@types/node": ">=20.11.20",
"@types/yargs": "^15.0.5",
"gts": "^2.0.2",
"typescript": "^3.8.3",
"typescript": "^5.1.3",
"yargs": "^15.4.1"
},
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/grpc-js-xds/src/http-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function validateTopLevelFilter(httpFilter: HttpFilter__Output): boolean
try {
typeUrl = getTopLevelFilterUrl(encodedConfig);
} catch (e) {
trace(httpFilter.name + ' validation failed with error ' + e.message);
trace(httpFilter.name + ' validation failed with error ' + (e as Error).message);
return false;
}
const registryEntry = FILTER_REGISTRY.get(typeUrl);
Expand Down Expand Up @@ -243,4 +243,4 @@ export function createHttpFilter(config: HttpFilterConfig, overrideConfig?: Http
} else {
return null;
}
}
}
6 changes: 3 additions & 3 deletions packages/grpc-js-xds/src/load-balancer-cds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ const RECURSION_DEPTH_LIMIT = 15;

/**
* Prerequisite: isClusterTreeFullyUpdated(tree, root)
* @param tree
* @param root
* @param tree
* @param root
*/
function getDiscoveryMechanismList(tree: ClusterTree, root: string): DiscoveryMechanism[] {
const visited = new Set<string>();
Expand Down Expand Up @@ -208,7 +208,7 @@ export class CdsLoadBalancer implements LoadBalancer {
try {
discoveryMechanismList = getDiscoveryMechanismList(this.clusterTree, this.latestConfig!.getCluster());
} catch (e) {
this.channelControlHelper.updateState(connectivityState.TRANSIENT_FAILURE, new UnavailablePicker({code: status.UNAVAILABLE, details: e.message, metadata: new Metadata()}));
this.channelControlHelper.updateState(connectivityState.TRANSIENT_FAILURE, new UnavailablePicker({code: status.UNAVAILABLE, details: (e as Error).message, metadata: new Metadata()}));
return;
}
const clusterResolverConfig = new XdsClusterResolverLoadBalancingConfig(
Expand Down
4 changes: 2 additions & 2 deletions packages/grpc-js-xds/src/load-balancer-priority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ export class PriorityLoadBalancer implements LoadBalancer {
private connectivityState: ConnectivityState = ConnectivityState.IDLE;
private picker: Picker;
private childBalancer: ChildLoadBalancerHandler;
private failoverTimer: NodeJS.Timer | null = null;
private deactivationTimer: NodeJS.Timer | null = null;
private failoverTimer: NodeJS.Timeout | null = null;
private deactivationTimer: NodeJS.Timeout | null = null;
private seenReadyOrIdleSinceTransientFailure = false;
constructor(private parent: PriorityLoadBalancer, private name: string, ignoreReresolutionRequests: boolean) {
this.childBalancer = new ChildLoadBalancerHandler(experimental.createChildChannelControlHelper(this.parent.channelControlHelper, {
Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-js-xds/src/load-balancer-weighted-target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class WeightedTargetLoadBalancer implements LoadBalancer {
private connectivityState: ConnectivityState = ConnectivityState.IDLE;
private picker: Picker;
private childBalancer: ChildLoadBalancerHandler;
private deactivationTimer: NodeJS.Timer | null = null;
private deactivationTimer: NodeJS.Timeout | null = null;
private weight: number = 0;

constructor(private parent: WeightedTargetLoadBalancer, private name: string) {
Expand Down
4 changes: 2 additions & 2 deletions packages/grpc-js-xds/src/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class SafeRegexValueMatcher implements ValueMatcher {
const numberRegex = new RE2(/^-?\d+$/u);

export class RangeValueMatcher implements ValueMatcher {
constructor(private start: BigInt, private end: BigInt) {}
constructor(private start: bigint, private end: bigint) {}

apply(value: string) {
if (!numberRegex.test(value)) {
Expand Down Expand Up @@ -264,4 +264,4 @@ export class FullMatcher implements Matcher {
headers: ${this.headerMatchers.map(matcher => matcher.toString()).join('\n\t')}
fraction: ${this.fraction ? fractionToString(this.fraction): 'none'}`;
}
}
}
4 changes: 2 additions & 2 deletions packages/grpc-js-xds/src/resolver-xds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ class XdsResolver implements Resolver {
this.isLdsWatcherActive = true;

} catch (e) {
this.reportResolutionError(e.message);
this.reportResolutionError((e as Error).message);
}
}
}
Expand All @@ -647,7 +647,7 @@ class XdsResolver implements Resolver {
try {
this.bootstrapInfo = loadBootstrapInfo();
} catch (e) {
this.reportResolutionError(e.message);
this.reportResolutionError((e as Error).message);
}
this.startResolution();
}
Expand Down
8 changes: 4 additions & 4 deletions packages/grpc-js-xds/src/xds-bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,14 +354,14 @@ export function loadBootstrapInfo(): BootstrapInfo {
try {
rawBootstrap = fs.readFileSync(bootstrapPath, { encoding: 'utf8'});
} catch (e) {
throw new Error(`Failed to read xDS bootstrap file from path ${bootstrapPath} with error ${e.message}`);
throw new Error(`Failed to read xDS bootstrap file from path ${bootstrapPath} with error ${(e as Error).message}`);
}
try {
const parsedFile = JSON.parse(rawBootstrap);
loadedBootstrapInfo = validateBootstrapConfig(parsedFile);
return loadedBootstrapInfo;
} catch (e) {
throw new Error(`Failed to parse xDS bootstrap file at path ${bootstrapPath} with error ${e.message}`)
throw new Error(`Failed to parse xDS bootstrap file at path ${bootstrapPath} with error ${(e as Error).message}`)
}
}

Expand All @@ -380,14 +380,14 @@ export function loadBootstrapInfo(): BootstrapInfo {
loadedBootstrapInfo = validateBootstrapConfig(parsedConfig);
} catch (e) {
throw new Error(
`Failed to parse xDS bootstrap config from environment variable GRPC_XDS_BOOTSTRAP_CONFIG with error ${e.message}`
`Failed to parse xDS bootstrap config from environment variable GRPC_XDS_BOOTSTRAP_CONFIG with error ${(e as Error).message}`
);
}

return loadedBootstrapInfo;
}


throw new Error(
'The GRPC_XDS_BOOTSTRAP or GRPC_XDS_BOOTSTRAP_CONFIG environment variables need to be set to the path to the bootstrap file to use xDS'
);
Expand Down
8 changes: 4 additions & 4 deletions packages/grpc-js-xds/src/xds-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class Watcher<UpdateType> implements ResourceWatcherInterface {
const RESOURCE_TIMEOUT_MS = 15_000;

class ResourceTimer {
private timer: NodeJS.Timer | null = null;
private timer: NodeJS.Timeout | null = null;
private resourceSeen = false;
constructor(private callState: AdsCallState, private type: XdsResourceType, private name: XdsResourceName) {}

Expand Down Expand Up @@ -208,14 +208,14 @@ class AdsResponseParser {
try {
decodeResult = this.result.type.decode(decodeContext, resource);
} catch (e) {
this.result.errors.push(`${errorPrefix} ${e.message}`);
this.result.errors.push(`${errorPrefix} ${(e as Error).message}`);
return;
}
let parsedName: XdsResourceName;
try {
parsedName = parseXdsResourceName(decodeResult.name, this.result.type!.getTypeUrl());
} catch (e) {
this.result.errors.push(`${errorPrefix} ${e.message}`);
this.result.errors.push(`${errorPrefix} ${(e as Error).message}`);
return;
}
this.adsCallState.typeStates.get(this.result.type!)?.subscribedResources.get(parsedName.authority)?.get(parsedName.key)?.markSeen();
Expand Down Expand Up @@ -666,7 +666,7 @@ class ClusterLoadReportMap {
}

class LrsCallState {
private statsTimer: NodeJS.Timer | null = null;
private statsTimer: NodeJS.Timeout | null = null;
private sentInitialMessage = false;
constructor(private client: XdsSingleServerClient, private call: LrsCall, private node: Node) {
call.on('data', (message: LoadStatsResponse__Output) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-js-xds/test/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const BOOTSTRAP_CONFIG_KEY = 'grpc.TEST_ONLY_DO_NOT_USE_IN_PROD.xds_bootstrap_co

export class XdsTestClient {
private client: EchoTestServiceClient;
private callInterval: NodeJS.Timer;
private callInterval: NodeJS.Timeout;

constructor(target: string, bootstrapInfo: string, options?: ChannelOptions) {
this.client = new loadedProtos.grpc.testing.EchoTestService(target, credentials.createInsecure(), {...options, [BOOTSTRAP_CONFIG_KEY]: bootstrapInfo});
Expand Down
28 changes: 15 additions & 13 deletions packages/grpc-js/test/fixtures/ca.pem
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla
Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0
YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT
BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7
+L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu
g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd
Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV
HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau
sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceEx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lgPL/Vk
-----END CERTIFICATE-----
29 changes: 15 additions & 14 deletions packages/grpc-js/test/fixtures/server1.pem
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
-----BEGIN CERTIFICATE-----
MIICnDCCAgWgAwIBAgIBBzANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTA0MDIyMDI0WhcNMjUxMTAx
MDIyMDI0WjBlMQswCQYDVQQGEwJVUzERMA8GA1UECBMISWxsaW5vaXMxEDAOBgNV
BAcTB0NoaWNhZ28xFTATBgNVBAoTDEV4YW1wbGUsIENvLjEaMBgGA1UEAxQRKi50
ZXN0Lmdvb2dsZS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAOHDFSco
LCVJpYDDM4HYtIdV6Ake/sMNaaKdODjDMsux/4tDydlumN+fm+AjPEK5GHhGn1Bg
zkWF+slf3BxhrA/8dNsnunstVA7ZBgA/5qQxMfGAq4wHNVX77fBZOgp9VlSMVfyd
9N8YwbBYAckOeUQadTi2X1S6OgJXgQ0m3MWhAgMBAAGjazBpMAkGA1UdEwQCMAAw
CwYDVR0PBAQDAgXgME8GA1UdEQRIMEaCECoudGVzdC5nb29nbGUuZnKCGHdhdGVy
em9vaS50ZXN0Lmdvb2dsZS5iZYISKi50ZXN0LnlvdXR1YmUuY29thwTAqAEDMA0G
CSqGSIb3DQEBCwUAA4GBAJFXVifQNub1LUP4JlnX5lXNlo8FxZ2a12AFQs+bzoJ6
hM044EDjqyxUqSbVePK0ni3w1fHQB5rY9yYC5f8G7aqqTY1QOhoUk8ZTSTRpnkTh
y4jjdvTZeLDVBlueZUTDRmy2feY5aZIU18vFDK08dTG0A87pppuv1LNIR3loveU8
MIICzDCCAjWgAwIBAgIBBzANBgkqhkiG9w0BAQ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