@netlify/plugin-nextjs 5.7.1 → 5.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ import {
10
10
  } from "../../esm-chunks/chunk-GNGHTHMQ.js";
11
11
  import {
12
12
  require_semver
13
- } from "../../esm-chunks/chunk-EFGWM7RS.js";
13
+ } from "../../esm-chunks/chunk-APO262HE.js";
14
14
  import {
15
15
  __commonJS,
16
16
  __esm,
@@ -30409,6 +30409,7 @@ var require_reader = __commonJS({
30409
30409
  case 5:
30410
30410
  this.skip(4);
30411
30411
  break;
30412
+ /* istanbul ignore next */
30412
30413
  default:
30413
30414
  throw Error("invalid wire type " + wireType + " at offset " + this.pos);
30414
30415
  }
@@ -39214,13 +39215,13 @@ var require_package2 = __commonJS({
39214
39215
  "node_modules/@grpc/grpc-js/package.json"(exports2, module2) {
39215
39216
  module2.exports = {
39216
39217
  name: "@grpc/grpc-js",
39217
- version: "1.10.1",
39218
+ version: "1.11.3",
39218
39219
  description: "gRPC Library for Node - pure JS implementation",
39219
39220
  homepage: "https://grpc.io/",
39220
39221
  repository: "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
39221
39222
  main: "build/src/index.js",
39222
39223
  engines: {
39223
- node: "^8.13.0 || >=10.10.0"
39224
+ node: ">=12.10.0"
39224
39225
  },
39225
39226
  keywords: [],
39226
39227
  author: {
@@ -39229,17 +39230,19 @@ var require_package2 = __commonJS({
39229
39230
  types: "build/src/index.d.ts",
39230
39231
  license: "Apache-2.0",
39231
39232
  devDependencies: {
39232
- "@types/gulp": "^4.0.6",
39233
- "@types/gulp-mocha": "0.0.32",
39234
- "@types/lodash": "^4.14.186",
39235
- "@types/mocha": "^5.2.6",
39236
- "@types/ncp": "^2.0.1",
39237
- "@types/pify": "^3.0.2",
39238
- "@types/semver": "^7.3.9",
39239
- "@typescript-eslint/eslint-plugin": "^5.59.11",
39240
- "@typescript-eslint/parser": "^5.59.11",
39241
- "@typescript-eslint/typescript-estree": "^5.59.11",
39242
- "clang-format": "^1.0.55",
39233
+ "@grpc/proto-loader": "file:../proto-loader",
39234
+ "@types/gulp": "^4.0.17",
39235
+ "@types/gulp-mocha": "0.0.37",
39236
+ "@types/lodash": "^4.14.202",
39237
+ "@types/mocha": "^10.0.6",
39238
+ "@types/ncp": "^2.0.8",
39239
+ "@types/node": ">=20.11.20",
39240
+ "@types/pify": "^5.0.4",
39241
+ "@types/semver": "^7.5.8",
39242
+ "@typescript-eslint/eslint-plugin": "^7.1.0",
39243
+ "@typescript-eslint/parser": "^7.1.0",
39244
+ "@typescript-eslint/typescript-estree": "^7.1.0",
39245
+ "clang-format": "^1.8.0",
39243
39246
  eslint: "^8.42.0",
39244
39247
  "eslint-config-prettier": "^8.8.0",
39245
39248
  "eslint-plugin-node": "^11.1.0",
@@ -39247,16 +39250,16 @@ var require_package2 = __commonJS({
39247
39250
  execa: "^2.0.3",
39248
39251
  gulp: "^4.0.2",
39249
39252
  "gulp-mocha": "^6.0.0",
39250
- lodash: "^4.17.4",
39253
+ lodash: "^4.17.21",
39251
39254
  madge: "^5.0.1",
39252
39255
  "mocha-jenkins-reporter": "^0.4.1",
39253
39256
  ncp: "^2.0.0",
39254
39257
  pify: "^4.0.1",
39255
39258
  prettier: "^2.8.8",
39256
39259
  rimraf: "^3.0.2",
39257
- semver: "^7.3.5",
39258
- "ts-node": "^10.9.1",
39259
- typescript: "^5.1.3"
39260
+ semver: "^7.6.0",
39261
+ "ts-node": "^10.9.2",
39262
+ typescript: "^5.3.3"
39260
39263
  },
39261
39264
  contributors: [
39262
39265
  {
@@ -39279,8 +39282,8 @@ var require_package2 = __commonJS({
39279
39282
  "generate-test-types": "proto-loader-gen-types --keepCase --longs String --enums String --defaults --oneofs --includeComments --include-dirs test/fixtures/ -O test/generated/ --grpcLib ../../src/index test_service.proto"
39280
39283
  },
39281
39284
  dependencies: {
39282
- "@grpc/proto-loader": "^0.7.8",
39283
- "@types/node": ">=12.12.47"
39285
+ "@grpc/proto-loader": "^0.7.13",
39286
+ "@js-sdsl/ordered-map": "^4.4.2"
39284
39287
  },
39285
39288
  files: [
39286
39289
  "src/**/*.ts",
@@ -40087,10 +40090,10 @@ var require_service_config = __commonJS({
40087
40090
  throw new Error("Invalid method config retry policy: maxAttempts must be an integer at least 2");
40088
40091
  }
40089
40092
  if (!("initialBackoff" in obj) || typeof obj.initialBackoff !== "string" || !DURATION_REGEX.test(obj.initialBackoff)) {
40090
- throw new Error("Invalid method config retry policy: initialBackoff must be a string consisting of a positive integer followed by s");
40093
+ throw new Error("Invalid method config retry policy: initialBackoff must be a string consisting of a positive integer or decimal followed by s");
40091
40094
  }
40092
40095
  if (!("maxBackoff" in obj) || typeof obj.maxBackoff !== "string" || !DURATION_REGEX.test(obj.maxBackoff)) {
40093
- throw new Error("Invalid method config retry policy: maxBackoff must be a string consisting of a positive integer followed by s");
40096
+ throw new Error("Invalid method config retry policy: maxBackoff must be a string consisting of a positive integer or decimal followed by s");
40094
40097
  }
40095
40098
  if (!("backoffMultiplier" in obj) || typeof obj.backoffMultiplier !== "number" || obj.backoffMultiplier <= 0) {
40096
40099
  throw new Error("Invalid method config retry policy: backoffMultiplier must be a number greater than 0");
@@ -40133,14 +40136,14 @@ var require_service_config = __commonJS({
40133
40136
  for (const value of obj.nonFatalStatusCodes) {
40134
40137
  if (typeof value === "number") {
40135
40138
  if (!Object.values(constants_1.Status).includes(value)) {
40136
- throw new Error("Invlid method config hedging policy: nonFatalStatusCodes value not in status code range");
40139
+ throw new Error("Invalid method config hedging policy: nonFatalStatusCodes value not in status code range");
40137
40140
  }
40138
40141
  } else if (typeof value === "string") {
40139
40142
  if (!Object.values(constants_1.Status).includes(value.toUpperCase())) {
40140
- throw new Error("Invlid method config hedging policy: nonFatalStatusCodes value not a status code name");
40143
+ throw new Error("Invalid method config hedging policy: nonFatalStatusCodes value not a status code name");
40141
40144
  }
40142
40145
  } else {
40143
- throw new Error("Invlid method config hedging policy: nonFatalStatusCodes value must be a string or number");
40146
+ throw new Error("Invalid method config hedging policy: nonFatalStatusCodes value must be a string or number");
40144
40147
  }
40145
40148
  }
40146
40149
  }
@@ -41151,7 +41154,8 @@ var require_channel_options = __commonJS({
41151
41154
  "grpc.service_config_disable_resolution": true,
41152
41155
  "grpc.client_idle_timeout_ms": true,
41153
41156
  "grpc-node.tls_enable_trace": true,
41154
- "grpc.lb.ring_hash.ring_size_cap": true
41157
+ "grpc.lb.ring_hash.ring_size_cap": true,
41158
+ "grpc-node.retry_max_attempts_limit": true
41155
41159
  };
41156
41160
  function channelOptionsEqual(options1, options2) {
41157
41161
  const keys1 = Object.keys(options1).sort();
@@ -41200,7 +41204,11 @@ var require_subchannel_address = __commonJS({
41200
41204
  exports2.subchannelAddressEqual = subchannelAddressEqual;
41201
41205
  function subchannelAddressToString(address) {
41202
41206
  if (isTcpSubchannelAddress(address)) {
41203
- return address.host + ":" + address.port;
41207
+ if ((0, net_1.isIPv6)(address.host)) {
41208
+ return "[" + address.host + "]:" + address.port;
41209
+ } else {
41210
+ return address.host + ":" + address.port;
41211
+ }
41204
41212
  } else {
41205
41213
  return address.path;
41206
41214
  }
@@ -41354,6 +41362,800 @@ var require_subchannel_address = __commonJS({
41354
41362
  }
41355
41363
  });
41356
41364
 
41365
+ // node_modules/@js-sdsl/ordered-map/dist/cjs/index.js
41366
+ var require_cjs = __commonJS({
41367
+ "node_modules/@js-sdsl/ordered-map/dist/cjs/index.js"(exports2) {
41368
+ "use strict";
41369
+ Object.defineProperty(exports2, "t", {
41370
+ value: true
41371
+ });
41372
+ var TreeNode = class {
41373
+ constructor(t, e, s = 1) {
41374
+ this.i = void 0;
41375
+ this.h = void 0;
41376
+ this.o = void 0;
41377
+ this.u = t;
41378
+ this.l = e;
41379
+ this.p = s;
41380
+ }
41381
+ I() {
41382
+ let t = this;
41383
+ const e = t.o.o === t;
41384
+ if (e && t.p === 1) {
41385
+ t = t.h;
41386
+ } else if (t.i) {
41387
+ t = t.i;
41388
+ while (t.h) {
41389
+ t = t.h;
41390
+ }
41391
+ } else {
41392
+ if (e) {
41393
+ return t.o;
41394
+ }
41395
+ let s = t.o;
41396
+ while (s.i === t) {
41397
+ t = s;
41398
+ s = t.o;
41399
+ }
41400
+ t = s;
41401
+ }
41402
+ return t;
41403
+ }
41404
+ B() {
41405
+ let t = this;
41406
+ if (t.h) {
41407
+ t = t.h;
41408
+ while (t.i) {
41409
+ t = t.i;
41410
+ }
41411
+ return t;
41412
+ } else {
41413
+ let e = t.o;
41414
+ while (e.h === t) {
41415
+ t = e;
41416
+ e = t.o;
41417
+ }
41418
+ if (t.h !== e) {
41419
+ return e;
41420
+ } else return t;
41421
+ }
41422
+ }
41423
+ _() {
41424
+ const t = this.o;
41425
+ const e = this.h;
41426
+ const s = e.i;
41427
+ if (t.o === this) t.o = e;
41428
+ else if (t.i === this) t.i = e;
41429
+ else t.h = e;
41430
+ e.o = t;
41431
+ e.i = this;
41432
+ this.o = e;
41433
+ this.h = s;
41434
+ if (s) s.o = this;
41435
+ return e;
41436
+ }
41437
+ g() {
41438
+ const t = this.o;
41439
+ const e = this.i;
41440
+ const s = e.h;
41441
+ if (t.o === this) t.o = e;
41442
+ else if (t.i === this) t.i = e;
41443
+ else t.h = e;
41444
+ e.o = t;
41445
+ e.h = this;
41446
+ this.o = e;
41447
+ this.i = s;
41448
+ if (s) s.o = this;
41449
+ return e;
41450
+ }
41451
+ };
41452
+ var TreeNodeEnableIndex = class extends TreeNode {
41453
+ constructor() {
41454
+ super(...arguments);
41455
+ this.M = 1;
41456
+ }
41457
+ _() {
41458
+ const t = super._();
41459
+ this.O();
41460
+ t.O();
41461
+ return t;
41462
+ }
41463
+ g() {
41464
+ const t = super.g();
41465
+ this.O();
41466
+ t.O();
41467
+ return t;
41468
+ }
41469
+ O() {
41470
+ this.M = 1;
41471
+ if (this.i) {
41472
+ this.M += this.i.M;
41473
+ }
41474
+ if (this.h) {
41475
+ this.M += this.h.M;
41476
+ }
41477
+ }
41478
+ };
41479
+ var ContainerIterator = class {
41480
+ constructor(t = 0) {
41481
+ this.iteratorType = t;
41482
+ }
41483
+ equals(t) {
41484
+ return this.T === t.T;
41485
+ }
41486
+ };
41487
+ var Base = class {
41488
+ constructor() {
41489
+ this.m = 0;
41490
+ }
41491
+ get length() {
41492
+ return this.m;
41493
+ }
41494
+ size() {
41495
+ return this.m;
41496
+ }
41497
+ empty() {
41498
+ return this.m === 0;
41499
+ }
41500
+ };
41501
+ var Container = class extends Base {
41502
+ };
41503
+ function throwIteratorAccessError() {
41504
+ throw new RangeError("Iterator access denied!");
41505
+ }
41506
+ var TreeContainer = class extends Container {
41507
+ constructor(t = function(t2, e2) {
41508
+ if (t2 < e2) return -1;
41509
+ if (t2 > e2) return 1;
41510
+ return 0;
41511
+ }, e = false) {
41512
+ super();
41513
+ this.v = void 0;
41514
+ this.A = t;
41515
+ this.enableIndex = e;
41516
+ this.N = e ? TreeNodeEnableIndex : TreeNode;
41517
+ this.C = new this.N();
41518
+ }
41519
+ R(t, e) {
41520
+ let s = this.C;
41521
+ while (t) {
41522
+ const i = this.A(t.u, e);
41523
+ if (i < 0) {
41524
+ t = t.h;
41525
+ } else if (i > 0) {
41526
+ s = t;
41527
+ t = t.i;
41528
+ } else return t;
41529
+ }
41530
+ return s;
41531
+ }
41532
+ K(t, e) {
41533
+ let s = this.C;
41534
+ while (t) {
41535
+ const i = this.A(t.u, e);
41536
+ if (i <= 0) {
41537
+ t = t.h;
41538
+ } else {
41539
+ s = t;
41540
+ t = t.i;
41541
+ }
41542
+ }
41543
+ return s;
41544
+ }
41545
+ L(t, e) {
41546
+ let s = this.C;
41547
+ while (t) {
41548
+ const i = this.A(t.u, e);
41549
+ if (i < 0) {
41550
+ s = t;
41551
+ t = t.h;
41552
+ } else if (i > 0) {
41553
+ t = t.i;
41554
+ } else return t;
41555
+ }
41556
+ return s;
41557
+ }
41558
+ k(t, e) {
41559
+ let s = this.C;
41560
+ while (t) {
41561
+ const i = this.A(t.u, e);
41562
+ if (i < 0) {
41563
+ s = t;
41564
+ t = t.h;
41565
+ } else {
41566
+ t = t.i;
41567
+ }
41568
+ }
41569
+ return s;
41570
+ }
41571
+ P(t) {
41572
+ while (true) {
41573
+ const e = t.o;
41574
+ if (e === this.C) return;
41575
+ if (t.p === 1) {
41576
+ t.p = 0;
41577
+ return;
41578
+ }
41579
+ if (t === e.i) {
41580
+ const s = e.h;
41581
+ if (s.p === 1) {
41582
+ s.p = 0;
41583
+ e.p = 1;
41584
+ if (e === this.v) {
41585
+ this.v = e._();
41586
+ } else e._();
41587
+ } else {
41588
+ if (s.h && s.h.p === 1) {
41589
+ s.p = e.p;
41590
+ e.p = 0;
41591
+ s.h.p = 0;
41592
+ if (e === this.v) {
41593
+ this.v = e._();
41594
+ } else e._();
41595
+ return;
41596
+ } else if (s.i && s.i.p === 1) {
41597
+ s.p = 1;
41598
+ s.i.p = 0;
41599
+ s.g();
41600
+ } else {
41601
+ s.p = 1;
41602
+ t = e;
41603
+ }
41604
+ }
41605
+ } else {
41606
+ const s = e.i;
41607
+ if (s.p === 1) {
41608
+ s.p = 0;
41609
+ e.p = 1;
41610
+ if (e === this.v) {
41611
+ this.v = e.g();
41612
+ } else e.g();
41613
+ } else {
41614
+ if (s.i && s.i.p === 1) {
41615
+ s.p = e.p;
41616
+ e.p = 0;
41617
+ s.i.p = 0;
41618
+ if (e === this.v) {
41619
+ this.v = e.g();
41620
+ } else e.g();
41621
+ return;
41622
+ } else if (s.h && s.h.p === 1) {
41623
+ s.p = 1;
41624
+ s.h.p = 0;
41625
+ s._();
41626
+ } else {
41627
+ s.p = 1;
41628
+ t = e;
41629
+ }
41630
+ }
41631
+ }
41632
+ }
41633
+ }
41634
+ S(t) {
41635
+ if (this.m === 1) {
41636
+ this.clear();
41637
+ return;
41638
+ }
41639
+ let e = t;
41640
+ while (e.i || e.h) {
41641
+ if (e.h) {
41642
+ e = e.h;
41643
+ while (e.i) e = e.i;
41644
+ } else {
41645
+ e = e.i;
41646
+ }
41647
+ const s2 = t.u;
41648
+ t.u = e.u;
41649
+ e.u = s2;
41650
+ const i = t.l;
41651
+ t.l = e.l;
41652
+ e.l = i;
41653
+ t = e;
41654
+ }
41655
+ if (this.C.i === e) {
41656
+ this.C.i = e.o;
41657
+ } else if (this.C.h === e) {
41658
+ this.C.h = e.o;
41659
+ }
41660
+ this.P(e);
41661
+ let s = e.o;
41662
+ if (e === s.i) {
41663
+ s.i = void 0;
41664
+ } else s.h = void 0;
41665
+ this.m -= 1;
41666
+ this.v.p = 0;
41667
+ if (this.enableIndex) {
41668
+ while (s !== this.C) {
41669
+ s.M -= 1;
41670
+ s = s.o;
41671
+ }
41672
+ }
41673
+ }
41674
+ U(t) {
41675
+ const e = typeof t === "number" ? t : void 0;
41676
+ const s = typeof t === "function" ? t : void 0;
41677
+ const i = typeof t === "undefined" ? [] : void 0;
41678
+ let r = 0;
41679
+ let n = this.v;
41680
+ const h = [];
41681
+ while (h.length || n) {
41682
+ if (n) {
41683
+ h.push(n);
41684
+ n = n.i;
41685
+ } else {
41686
+ n = h.pop();
41687
+ if (r === e) return n;
41688
+ i && i.push(n);
41689
+ s && s(n, r, this);
41690
+ r += 1;
41691
+ n = n.h;
41692
+ }
41693
+ }
41694
+ return i;
41695
+ }
41696
+ j(t) {
41697
+ while (true) {
41698
+ const e = t.o;
41699
+ if (e.p === 0) return;
41700
+ const s = e.o;
41701
+ if (e === s.i) {
41702
+ const i = s.h;
41703
+ if (i && i.p === 1) {
41704
+ i.p = e.p = 0;
41705
+ if (s === this.v) return;
41706
+ s.p = 1;
41707
+ t = s;
41708
+ continue;
41709
+ } else if (t === e.h) {
41710
+ t.p = 0;
41711
+ if (t.i) {
41712
+ t.i.o = e;
41713
+ }
41714
+ if (t.h) {
41715
+ t.h.o = s;
41716
+ }
41717
+ e.h = t.i;
41718
+ s.i = t.h;
41719
+ t.i = e;
41720
+ t.h = s;
41721
+ if (s === this.v) {
41722
+ this.v = t;
41723
+ this.C.o = t;
41724
+ } else {
41725
+ const e2 = s.o;
41726
+ if (e2.i === s) {
41727
+ e2.i = t;
41728
+ } else e2.h = t;
41729
+ }
41730
+ t.o = s.o;
41731
+ e.o = t;
41732
+ s.o = t;
41733
+ s.p = 1;
41734
+ } else {
41735
+ e.p = 0;
41736
+ if (s === this.v) {
41737
+ this.v = s.g();
41738
+ } else s.g();
41739
+ s.p = 1;
41740
+ return;
41741
+ }
41742
+ } else {
41743
+ const i = s.i;
41744
+ if (i && i.p === 1) {
41745
+ i.p = e.p = 0;
41746
+ if (s === this.v) return;
41747
+ s.p = 1;
41748
+ t = s;
41749
+ continue;
41750
+ } else if (t === e.i) {
41751
+ t.p = 0;
41752
+ if (t.i) {
41753
+ t.i.o = s;
41754
+ }
41755
+ if (t.h) {
41756
+ t.h.o = e;
41757
+ }
41758
+ s.h = t.i;
41759
+ e.i = t.h;
41760
+ t.i = s;
41761
+ t.h = e;
41762
+ if (s === this.v) {
41763
+ this.v = t;
41764
+ this.C.o = t;
41765
+ } else {
41766
+ const e2 = s.o;
41767
+ if (e2.i === s) {
41768
+ e2.i = t;
41769
+ } else e2.h = t;
41770
+ }
41771
+ t.o = s.o;
41772
+ e.o = t;
41773
+ s.o = t;
41774
+ s.p = 1;
41775
+ } else {
41776
+ e.p = 0;
41777
+ if (s === this.v) {
41778
+ this.v = s._();
41779
+ } else s._();
41780
+ s.p = 1;
41781
+ return;
41782
+ }
41783
+ }
41784
+ if (this.enableIndex) {
41785
+ e.O();
41786
+ s.O();
41787
+ t.O();
41788
+ }
41789
+ return;
41790
+ }
41791
+ }
41792
+ q(t, e, s) {
41793
+ if (this.v === void 0) {
41794
+ this.m += 1;
41795
+ this.v = new this.N(t, e, 0);
41796
+ this.v.o = this.C;
41797
+ this.C.o = this.C.i = this.C.h = this.v;
41798
+ return this.m;
41799
+ }
41800
+ let i;
41801
+ const r = this.C.i;
41802
+ const n = this.A(r.u, t);
41803
+ if (n === 0) {
41804
+ r.l = e;
41805
+ return this.m;
41806
+ } else if (n > 0) {
41807
+ r.i = new this.N(t, e);
41808
+ r.i.o = r;
41809
+ i = r.i;
41810
+ this.C.i = i;
41811
+ } else {
41812
+ const r2 = this.C.h;
41813
+ const n2 = this.A(r2.u, t);
41814
+ if (n2 === 0) {
41815
+ r2.l = e;
41816
+ return this.m;
41817
+ } else if (n2 < 0) {
41818
+ r2.h = new this.N(t, e);
41819
+ r2.h.o = r2;
41820
+ i = r2.h;
41821
+ this.C.h = i;
41822
+ } else {
41823
+ if (s !== void 0) {
41824
+ const r3 = s.T;
41825
+ if (r3 !== this.C) {
41826
+ const s2 = this.A(r3.u, t);
41827
+ if (s2 === 0) {
41828
+ r3.l = e;
41829
+ return this.m;
41830
+ } else if (s2 > 0) {
41831
+ const s3 = r3.I();
41832
+ const n3 = this.A(s3.u, t);
41833
+ if (n3 === 0) {
41834
+ s3.l = e;
41835
+ return this.m;
41836
+ } else if (n3 < 0) {
41837
+ i = new this.N(t, e);
41838
+ if (s3.h === void 0) {
41839
+ s3.h = i;
41840
+ i.o = s3;
41841
+ } else {
41842
+ r3.i = i;
41843
+ i.o = r3;
41844
+ }
41845
+ }
41846
+ }
41847
+ }
41848
+ }
41849
+ if (i === void 0) {
41850
+ i = this.v;
41851
+ while (true) {
41852
+ const s2 = this.A(i.u, t);
41853
+ if (s2 > 0) {
41854
+ if (i.i === void 0) {
41855
+ i.i = new this.N(t, e);
41856
+ i.i.o = i;
41857
+ i = i.i;
41858
+ break;
41859
+ }
41860
+ i = i.i;
41861
+ } else if (s2 < 0) {
41862
+ if (i.h === void 0) {
41863
+ i.h = new this.N(t, e);
41864
+ i.h.o = i;
41865
+ i = i.h;
41866
+ break;
41867
+ }
41868
+ i = i.h;
41869
+ } else {
41870
+ i.l = e;
41871
+ return this.m;
41872
+ }
41873
+ }
41874
+ }
41875
+ }
41876
+ }
41877
+ if (this.enableIndex) {
41878
+ let t2 = i.o;
41879
+ while (t2 !== this.C) {
41880
+ t2.M += 1;
41881
+ t2 = t2.o;
41882
+ }
41883
+ }
41884
+ this.j(i);
41885
+ this.m += 1;
41886
+ return this.m;
41887
+ }
41888
+ H(t, e) {
41889
+ while (t) {
41890
+ const s = this.A(t.u, e);
41891
+ if (s < 0) {
41892
+ t = t.h;
41893
+ } else if (s > 0) {
41894
+ t = t.i;
41895
+ } else return t;
41896
+ }
41897
+ return t || this.C;
41898
+ }
41899
+ clear() {
41900
+ this.m = 0;
41901
+ this.v = void 0;
41902
+ this.C.o = void 0;
41903
+ this.C.i = this.C.h = void 0;
41904
+ }
41905
+ updateKeyByIterator(t, e) {
41906
+ const s = t.T;
41907
+ if (s === this.C) {
41908
+ throwIteratorAccessError();
41909
+ }
41910
+ if (this.m === 1) {
41911
+ s.u = e;
41912
+ return true;
41913
+ }
41914
+ const i = s.B().u;
41915
+ if (s === this.C.i) {
41916
+ if (this.A(i, e) > 0) {
41917
+ s.u = e;
41918
+ return true;
41919
+ }
41920
+ return false;
41921
+ }
41922
+ const r = s.I().u;
41923
+ if (s === this.C.h) {
41924
+ if (this.A(r, e) < 0) {
41925
+ s.u = e;
41926
+ return true;
41927
+ }
41928
+ return false;
41929
+ }
41930
+ if (this.A(r, e) >= 0 || this.A(i, e) <= 0) return false;
41931
+ s.u = e;
41932
+ return true;
41933
+ }
41934
+ eraseElementByPos(t) {
41935
+ if (t < 0 || t > this.m - 1) {
41936
+ throw new RangeError();
41937
+ }
41938
+ const e = this.U(t);
41939
+ this.S(e);
41940
+ return this.m;
41941
+ }
41942
+ eraseElementByKey(t) {
41943
+ if (this.m === 0) return false;
41944
+ const e = this.H(this.v, t);
41945
+ if (e === this.C) return false;
41946
+ this.S(e);
41947
+ return true;
41948
+ }
41949
+ eraseElementByIterator(t) {
41950
+ const e = t.T;
41951
+ if (e === this.C) {
41952
+ throwIteratorAccessError();
41953
+ }
41954
+ const s = e.h === void 0;
41955
+ const i = t.iteratorType === 0;
41956
+ if (i) {
41957
+ if (s) t.next();
41958
+ } else {
41959
+ if (!s || e.i === void 0) t.next();
41960
+ }
41961
+ this.S(e);
41962
+ return t;
41963
+ }
41964
+ getHeight() {
41965
+ if (this.m === 0) return 0;
41966
+ function traversal(t) {
41967
+ if (!t) return 0;
41968
+ return Math.max(traversal(t.i), traversal(t.h)) + 1;
41969
+ }
41970
+ return traversal(this.v);
41971
+ }
41972
+ };
41973
+ var TreeIterator = class extends ContainerIterator {
41974
+ constructor(t, e, s) {
41975
+ super(s);
41976
+ this.T = t;
41977
+ this.C = e;
41978
+ if (this.iteratorType === 0) {
41979
+ this.pre = function() {
41980
+ if (this.T === this.C.i) {
41981
+ throwIteratorAccessError();
41982
+ }
41983
+ this.T = this.T.I();
41984
+ return this;
41985
+ };
41986
+ this.next = function() {
41987
+ if (this.T === this.C) {
41988
+ throwIteratorAccessError();
41989
+ }
41990
+ this.T = this.T.B();
41991
+ return this;
41992
+ };
41993
+ } else {
41994
+ this.pre = function() {
41995
+ if (this.T === this.C.h) {
41996
+ throwIteratorAccessError();
41997
+ }
41998
+ this.T = this.T.B();
41999
+ return this;
42000
+ };
42001
+ this.next = function() {
42002
+ if (this.T === this.C) {
42003
+ throwIteratorAccessError();
42004
+ }
42005
+ this.T = this.T.I();
42006
+ return this;
42007
+ };
42008
+ }
42009
+ }
42010
+ get index() {
42011
+ let t = this.T;
42012
+ const e = this.C.o;
42013
+ if (t === this.C) {
42014
+ if (e) {
42015
+ return e.M - 1;
42016
+ }
42017
+ return 0;
42018
+ }
42019
+ let s = 0;
42020
+ if (t.i) {
42021
+ s += t.i.M;
42022
+ }
42023
+ while (t !== e) {
42024
+ const e2 = t.o;
42025
+ if (t === e2.h) {
42026
+ s += 1;
42027
+ if (e2.i) {
42028
+ s += e2.i.M;
42029
+ }
42030
+ }
42031
+ t = e2;
42032
+ }
42033
+ return s;
42034
+ }
42035
+ isAccessible() {
42036
+ return this.T !== this.C;
42037
+ }
42038
+ };
42039
+ var OrderedMapIterator = class _OrderedMapIterator extends TreeIterator {
42040
+ constructor(t, e, s, i) {
42041
+ super(t, e, i);
42042
+ this.container = s;
42043
+ }
42044
+ get pointer() {
42045
+ if (this.T === this.C) {
42046
+ throwIteratorAccessError();
42047
+ }
42048
+ const t = this;
42049
+ return new Proxy([], {
42050
+ get(e, s) {
42051
+ if (s === "0") return t.T.u;
42052
+ else if (s === "1") return t.T.l;
42053
+ e[0] = t.T.u;
42054
+ e[1] = t.T.l;
42055
+ return e[s];
42056
+ },
42057
+ set(e, s, i) {
42058
+ if (s !== "1") {
42059
+ throw new TypeError("prop must be 1");
42060
+ }
42061
+ t.T.l = i;
42062
+ return true;
42063
+ }
42064
+ });
42065
+ }
42066
+ copy() {
42067
+ return new _OrderedMapIterator(this.T, this.C, this.container, this.iteratorType);
42068
+ }
42069
+ };
42070
+ var OrderedMap = class extends TreeContainer {
42071
+ constructor(t = [], e, s) {
42072
+ super(e, s);
42073
+ const i = this;
42074
+ t.forEach(function(t2) {
42075
+ i.setElement(t2[0], t2[1]);
42076
+ });
42077
+ }
42078
+ begin() {
42079
+ return new OrderedMapIterator(this.C.i || this.C, this.C, this);
42080
+ }
42081
+ end() {
42082
+ return new OrderedMapIterator(this.C, this.C, this);
42083
+ }
42084
+ rBegin() {
42085
+ return new OrderedMapIterator(this.C.h || this.C, this.C, this, 1);
42086
+ }
42087
+ rEnd() {
42088
+ return new OrderedMapIterator(this.C, this.C, this, 1);
42089
+ }
42090
+ front() {
42091
+ if (this.m === 0) return;
42092
+ const t = this.C.i;
42093
+ return [t.u, t.l];
42094
+ }
42095
+ back() {
42096
+ if (this.m === 0) return;
42097
+ const t = this.C.h;
42098
+ return [t.u, t.l];
42099
+ }
42100
+ lowerBound(t) {
42101
+ const e = this.R(this.v, t);
42102
+ return new OrderedMapIterator(e, this.C, this);
42103
+ }
42104
+ upperBound(t) {
42105
+ const e = this.K(this.v, t);
42106
+ return new OrderedMapIterator(e, this.C, this);
42107
+ }
42108
+ reverseLowerBound(t) {
42109
+ const e = this.L(this.v, t);
42110
+ return new OrderedMapIterator(e, this.C, this);
42111
+ }
42112
+ reverseUpperBound(t) {
42113
+ const e = this.k(this.v, t);
42114
+ return new OrderedMapIterator(e, this.C, this);
42115
+ }
42116
+ forEach(t) {
42117
+ this.U(function(e, s, i) {
42118
+ t([e.u, e.l], s, i);
42119
+ });
42120
+ }
42121
+ setElement(t, e, s) {
42122
+ return this.q(t, e, s);
42123
+ }
42124
+ getElementByPos(t) {
42125
+ if (t < 0 || t > this.m - 1) {
42126
+ throw new RangeError();
42127
+ }
42128
+ const e = this.U(t);
42129
+ return [e.u, e.l];
42130
+ }
42131
+ find(t) {
42132
+ const e = this.H(this.v, t);
42133
+ return new OrderedMapIterator(e, this.C, this);
42134
+ }
42135
+ getElementByKey(t) {
42136
+ const e = this.H(this.v, t);
42137
+ return e.l;
42138
+ }
42139
+ union(t) {
42140
+ const e = this;
42141
+ t.forEach(function(t2) {
42142
+ e.setElement(t2[0], t2[1]);
42143
+ });
42144
+ return this.m;
42145
+ }
42146
+ *[Symbol.iterator]() {
42147
+ const t = this.m;
42148
+ const e = this.U();
42149
+ for (let s = 0; s < t; ++s) {
42150
+ const t2 = e[s];
42151
+ yield [t2.u, t2.l];
42152
+ }
42153
+ }
42154
+ };
42155
+ exports2.OrderedMap = OrderedMap;
42156
+ }
42157
+ });
42158
+
41357
42159
  // node_modules/@grpc/grpc-js/build/src/admin.js
41358
42160
  var require_admin = __commonJS({
41359
42161
  "node_modules/@grpc/grpc-js/build/src/admin.js"(exports2) {
@@ -41930,7 +42732,8 @@ var require_client = __commonJS({
41930
42732
  return typeof arg === "function";
41931
42733
  }
41932
42734
  function getErrorStackString(error) {
41933
- return error.stack.split("\n").slice(1).join("\n");
42735
+ var _a;
42736
+ return ((_a = error.stack) === null || _a === void 0 ? void 0 : _a.split("\n").slice(1).join("\n")) || "no stack trace available";
41934
42737
  }
41935
42738
  var Client = class {
41936
42739
  constructor(address, credentials, options = {}) {
@@ -42043,7 +42846,7 @@ var require_client = __commonJS({
42043
42846
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
42044
42847
  onReceiveMessage(message) {
42045
42848
  if (responseMessage !== null) {
42046
- call.cancelWithStatus(constants_1.Status.INTERNAL, "Too many responses received");
42849
+ call.cancelWithStatus(constants_1.Status.UNIMPLEMENTED, "Too many responses received");
42047
42850
  }
42048
42851
  responseMessage = message;
42049
42852
  },
@@ -42056,7 +42859,7 @@ var require_client = __commonJS({
42056
42859
  if (responseMessage === null) {
42057
42860
  const callerStack = getErrorStackString(callerStackError);
42058
42861
  callProperties.callback((0, call_1.callErrorFromStatus)({
42059
- code: constants_1.Status.INTERNAL,
42862
+ code: constants_1.Status.UNIMPLEMENTED,
42060
42863
  details: "No message received",
42061
42864
  metadata: status.metadata
42062
42865
  }, callerStack));
@@ -42115,9 +42918,10 @@ var require_client = __commonJS({
42115
42918
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
42116
42919
  onReceiveMessage(message) {
42117
42920
  if (responseMessage !== null) {
42118
- call.cancelWithStatus(constants_1.Status.INTERNAL, "Too many responses received");
42921
+ call.cancelWithStatus(constants_1.Status.UNIMPLEMENTED, "Too many responses received");
42119
42922
  }
42120
42923
  responseMessage = message;
42924
+ call.startRead();
42121
42925
  },
42122
42926
  onReceiveStatus(status) {
42123
42927
  if (receivedStatus) {
@@ -42128,7 +42932,7 @@ var require_client = __commonJS({
42128
42932
  if (responseMessage === null) {
42129
42933
  const callerStack = getErrorStackString(callerStackError);
42130
42934
  callProperties.callback((0, call_1.callErrorFromStatus)({
42131
- code: constants_1.Status.INTERNAL,
42935
+ code: constants_1.Status.UNIMPLEMENTED,
42132
42936
  details: "No message received",
42133
42937
  metadata: status.metadata
42134
42938
  }, callerStack));
@@ -44014,6 +44818,7 @@ var require_converter = __commonJS({
44014
44818
  break;
44015
44819
  case "uint64":
44016
44820
  isUnsigned = true;
44821
+ // eslint-disable-next-line no-fallthrough
44017
44822
  case "int64":
44018
44823
  case "sint64":
44019
44824
  case "fixed64":
@@ -44085,6 +44890,7 @@ var require_converter = __commonJS({
44085
44890
  break;
44086
44891
  case "uint64":
44087
44892
  isUnsigned = true;
44893
+ // eslint-disable-next-line no-fallthrough
44088
44894
  case "int64":
44089
44895
  case "sint64":
44090
44896
  case "fixed64":
@@ -45632,6 +46438,7 @@ var require_parse = __commonJS({
45632
46438
  break;
45633
46439
  case "public":
45634
46440
  next();
46441
+ // eslint-disable-next-line no-fallthrough
45635
46442
  default:
45636
46443
  whichImports = imports || (imports = []);
45637
46444
  break;
@@ -45809,6 +46616,7 @@ var require_parse = __commonJS({
45809
46616
  case "enum":
45810
46617
  parseEnum(type, token2);
45811
46618
  break;
46619
+ /* istanbul ignore next */
45812
46620
  default:
45813
46621
  throw illegal(token2);
45814
46622
  }
@@ -47368,6 +48176,7 @@ var require_descriptor2 = __commonJS({
47368
48176
  fieldType = fromDescriptorType(descriptor.type);
47369
48177
  var fieldRule;
47370
48178
  switch (descriptor.label) {
48179
+ // 0 is reserved for errors
47371
48180
  case 1:
47372
48181
  fieldRule = void 0;
47373
48182
  break;
@@ -47429,7 +48238,9 @@ var require_descriptor2 = __commonJS({
47429
48238
  } else {
47430
48239
  switch (descriptor.type = toDescriptorType(this.type, this.resolve().resolvedType)) {
47431
48240
  case 10:
48241
+ // group
47432
48242
  case 11:
48243
+ // type
47433
48244
  case 14:
47434
48245
  descriptor.typeName = this.resolvedType ? shortname(this.parent, this.resolvedType) : this.type;
47435
48246
  break;
@@ -47552,6 +48363,7 @@ var require_descriptor2 = __commonJS({
47552
48363
  };
47553
48364
  function fromDescriptorType(type) {
47554
48365
  switch (type) {
48366
+ // 0 is reserved for errors
47555
48367
  case 1:
47556
48368
  return "double";
47557
48369
  case 2:
@@ -47588,18 +48400,31 @@ var require_descriptor2 = __commonJS({
47588
48400
  function packableDescriptorType(type) {
47589
48401
  switch (type) {
47590
48402
  case 1:
48403
+ // double
47591
48404
  case 2:
48405
+ // float
47592
48406
  case 3:
48407
+ // int64
47593
48408
  case 4:
48409
+ // uint64
47594
48410
  case 5:
48411
+ // int32
47595
48412
  case 6:
48413
+ // fixed64
47596
48414
  case 7:
48415
+ // fixed32
47597
48416
  case 8:
48417
+ // bool
47598
48418
  case 13:
48419
+ // uint32
47599
48420
  case 14:
48421
+ // enum (!)
47600
48422
  case 15:
48423
+ // sfixed32
47601
48424
  case 16:
48425
+ // sfixed64
47602
48426
  case 17:
48427
+ // sint32
47603
48428
  case 18:
47604
48429
  return true;
47605
48430
  }
@@ -47607,6 +48432,7 @@ var require_descriptor2 = __commonJS({
47607
48432
  }
47608
48433
  function toDescriptorType(type, resolvedType) {
47609
48434
  switch (type) {
48435
+ // 0 is reserved for errors
47610
48436
  case "double":
47611
48437
  return 1;
47612
48438
  case "float":
@@ -48641,7 +49467,7 @@ var require_src30 = __commonJS({
48641
49467
  "node_modules/@grpc/proto-loader/build/src/index.js"(exports2) {
48642
49468
  "use strict";
48643
49469
  Object.defineProperty(exports2, "__esModule", { value: true });
48644
- exports2.loadFileDescriptorSetFromObject = exports2.loadFileDescriptorSetFromBuffer = exports2.fromJSON = exports2.loadSync = exports2.load = exports2.isAnyExtension = exports2.Long = void 0;
49470
+ exports2.loadFileDescriptorSetFromObject = exports2.loadFileDescriptorSetFromBuffer = exports2.fromJSON = exports2.loadSync = exports2.load = exports2.IdempotencyLevel = exports2.isAnyExtension = exports2.Long = void 0;
48645
49471
  var camelCase = require_lodash();
48646
49472
  var Protobuf = require_protobufjs();
48647
49473
  var descriptor = require_descriptor2();
@@ -48652,6 +49478,12 @@ var require_src30 = __commonJS({
48652
49478
  return "@type" in obj && typeof obj["@type"] === "string";
48653
49479
  }
48654
49480
  exports2.isAnyExtension = isAnyExtension;
49481
+ var IdempotencyLevel;
49482
+ (function(IdempotencyLevel2) {
49483
+ IdempotencyLevel2["IDEMPOTENCY_UNKNOWN"] = "IDEMPOTENCY_UNKNOWN";
49484
+ IdempotencyLevel2["NO_SIDE_EFFECTS"] = "NO_SIDE_EFFECTS";
49485
+ IdempotencyLevel2["IDEMPOTENT"] = "IDEMPOTENT";
49486
+ })(IdempotencyLevel = exports2.IdempotencyLevel || (exports2.IdempotencyLevel = {}));
48655
49487
  var descriptorOptions = {
48656
49488
  longs: String,
48657
49489
  enums: String,
@@ -48700,6 +49532,24 @@ var require_src30 = __commonJS({
48700
49532
  return cls.encode(message).finish();
48701
49533
  };
48702
49534
  }
49535
+ function mapMethodOptions(options) {
49536
+ return (options || []).reduce((obj, item) => {
49537
+ for (const [key, value] of Object.entries(item)) {
49538
+ switch (key) {
49539
+ case "uninterpreted_option":
49540
+ obj.uninterpreted_option.push(item.uninterpreted_option);
49541
+ break;
49542
+ default:
49543
+ obj[key] = value;
49544
+ }
49545
+ }
49546
+ return obj;
49547
+ }, {
49548
+ deprecated: false,
49549
+ idempotency_level: IdempotencyLevel.IDEMPOTENCY_UNKNOWN,
49550
+ uninterpreted_option: []
49551
+ });
49552
+ }
48703
49553
  function createMethodDefinition(method, serviceName, options, fileDescriptors) {
48704
49554
  const requestType = method.resolvedRequestType;
48705
49555
  const responseType = method.resolvedResponseType;
@@ -48714,7 +49564,8 @@ var require_src30 = __commonJS({
48714
49564
  // TODO(murgatroid99): Find a better way to handle this
48715
49565
  originalName: camelCase(method.name),
48716
49566
  requestType: createMessageDefinition(requestType, fileDescriptors),
48717
- responseType: createMessageDefinition(responseType, fileDescriptors)
49567
+ responseType: createMessageDefinition(responseType, fileDescriptors),
49568
+ options: mapMethodOptions(method.parsedOptions)
48718
49569
  };
48719
49570
  }
48720
49571
  function createServiceDefinition(service, name2, options, fileDescriptors) {
@@ -48804,8 +49655,9 @@ var require_channelz = __commonJS({
48804
49655
  "node_modules/@grpc/grpc-js/build/src/channelz.js"(exports2) {
48805
49656
  "use strict";
48806
49657
  Object.defineProperty(exports2, "__esModule", { value: true });
48807
- exports2.setup = exports2.getChannelzServiceDefinition = exports2.getChannelzHandlers = exports2.unregisterChannelzRef = exports2.registerChannelzSocket = exports2.registerChannelzServer = exports2.registerChannelzSubchannel = exports2.registerChannelzChannel = exports2.ChannelzCallTracker = exports2.ChannelzChildrenTracker = exports2.ChannelzTrace = void 0;
49658
+ exports2.setup = exports2.getChannelzServiceDefinition = exports2.getChannelzHandlers = exports2.unregisterChannelzRef = exports2.registerChannelzSocket = exports2.registerChannelzServer = exports2.registerChannelzSubchannel = exports2.registerChannelzChannel = exports2.ChannelzCallTrackerStub = exports2.ChannelzCallTracker = exports2.ChannelzChildrenTrackerStub = exports2.ChannelzChildrenTracker = exports2.ChannelzTrace = exports2.ChannelzTraceStub = void 0;
48808
49659
  var net_1 = __require("net");
49660
+ var ordered_map_1 = require_cjs();
48809
49661
  var connectivity_state_1 = require_connectivity_state();
48810
49662
  var constants_1 = require_constants8();
48811
49663
  var subchannel_address_1 = require_subchannel_address();
@@ -48835,6 +49687,24 @@ var require_channelz = __commonJS({
48835
49687
  };
48836
49688
  }
48837
49689
  var TARGET_RETAINED_TRACES = 32;
49690
+ var DEFAULT_MAX_RESULTS = 100;
49691
+ var ChannelzTraceStub = class {
49692
+ constructor() {
49693
+ this.events = [];
49694
+ this.creationTimestamp = /* @__PURE__ */ new Date();
49695
+ this.eventsLogged = 0;
49696
+ }
49697
+ addTrace() {
49698
+ }
49699
+ getTraceMessage() {
49700
+ return {
49701
+ creation_timestamp: dateToProtoTimestamp(this.creationTimestamp),
49702
+ num_events_logged: this.eventsLogged,
49703
+ events: []
49704
+ };
49705
+ }
49706
+ };
49707
+ exports2.ChannelzTraceStub = ChannelzTraceStub;
48838
49708
  var ChannelzTrace = class {
48839
49709
  constructor() {
48840
49710
  this.events = [];
@@ -48874,99 +49744,62 @@ var require_channelz = __commonJS({
48874
49744
  exports2.ChannelzTrace = ChannelzTrace;
48875
49745
  var ChannelzChildrenTracker = class {
48876
49746
  constructor() {
48877
- this.channelChildren = /* @__PURE__ */ new Map();
48878
- this.subchannelChildren = /* @__PURE__ */ new Map();
48879
- this.socketChildren = /* @__PURE__ */ new Map();
49747
+ this.channelChildren = new ordered_map_1.OrderedMap();
49748
+ this.subchannelChildren = new ordered_map_1.OrderedMap();
49749
+ this.socketChildren = new ordered_map_1.OrderedMap();
49750
+ this.trackerMap = {
49751
+ [
49752
+ "channel"
49753
+ /* EntityTypes.channel */
49754
+ ]: this.channelChildren,
49755
+ [
49756
+ "subchannel"
49757
+ /* EntityTypes.subchannel */
49758
+ ]: this.subchannelChildren,
49759
+ [
49760
+ "socket"
49761
+ /* EntityTypes.socket */
49762
+ ]: this.socketChildren
49763
+ };
48880
49764
  }
48881
49765
  refChild(child) {
48882
- var _a, _b, _c;
48883
- switch (child.kind) {
48884
- case "channel": {
48885
- const trackedChild = (_a = this.channelChildren.get(child.id)) !== null && _a !== void 0 ? _a : {
48886
- ref: child,
48887
- count: 0
48888
- };
48889
- trackedChild.count += 1;
48890
- this.channelChildren.set(child.id, trackedChild);
48891
- break;
48892
- }
48893
- case "subchannel": {
48894
- const trackedChild = (_b = this.subchannelChildren.get(child.id)) !== null && _b !== void 0 ? _b : {
48895
- ref: child,
48896
- count: 0
48897
- };
48898
- trackedChild.count += 1;
48899
- this.subchannelChildren.set(child.id, trackedChild);
48900
- break;
48901
- }
48902
- case "socket": {
48903
- const trackedChild = (_c = this.socketChildren.get(child.id)) !== null && _c !== void 0 ? _c : {
48904
- ref: child,
48905
- count: 0
48906
- };
48907
- trackedChild.count += 1;
48908
- this.socketChildren.set(child.id, trackedChild);
48909
- break;
48910
- }
49766
+ const tracker = this.trackerMap[child.kind];
49767
+ const trackedChild = tracker.find(child.id);
49768
+ if (trackedChild.equals(tracker.end())) {
49769
+ tracker.setElement(child.id, {
49770
+ ref: child,
49771
+ count: 1
49772
+ }, trackedChild);
49773
+ } else {
49774
+ trackedChild.pointer[1].count += 1;
48911
49775
  }
48912
49776
  }
48913
49777
  unrefChild(child) {
48914
- switch (child.kind) {
48915
- case "channel": {
48916
- const trackedChild = this.channelChildren.get(child.id);
48917
- if (trackedChild !== void 0) {
48918
- trackedChild.count -= 1;
48919
- if (trackedChild.count === 0) {
48920
- this.channelChildren.delete(child.id);
48921
- } else {
48922
- this.channelChildren.set(child.id, trackedChild);
48923
- }
48924
- }
48925
- break;
48926
- }
48927
- case "subchannel": {
48928
- const trackedChild = this.subchannelChildren.get(child.id);
48929
- if (trackedChild !== void 0) {
48930
- trackedChild.count -= 1;
48931
- if (trackedChild.count === 0) {
48932
- this.subchannelChildren.delete(child.id);
48933
- } else {
48934
- this.subchannelChildren.set(child.id, trackedChild);
48935
- }
48936
- }
48937
- break;
48938
- }
48939
- case "socket": {
48940
- const trackedChild = this.socketChildren.get(child.id);
48941
- if (trackedChild !== void 0) {
48942
- trackedChild.count -= 1;
48943
- if (trackedChild.count === 0) {
48944
- this.socketChildren.delete(child.id);
48945
- } else {
48946
- this.socketChildren.set(child.id, trackedChild);
48947
- }
48948
- }
48949
- break;
49778
+ const tracker = this.trackerMap[child.kind];
49779
+ const trackedChild = tracker.getElementByKey(child.id);
49780
+ if (trackedChild !== void 0) {
49781
+ trackedChild.count -= 1;
49782
+ if (trackedChild.count === 0) {
49783
+ tracker.eraseElementByKey(child.id);
48950
49784
  }
48951
49785
  }
48952
49786
  }
48953
49787
  getChildLists() {
48954
- const channels2 = [];
48955
- for (const { ref } of this.channelChildren.values()) {
48956
- channels2.push(ref);
48957
- }
48958
- const subchannels2 = [];
48959
- for (const { ref } of this.subchannelChildren.values()) {
48960
- subchannels2.push(ref);
48961
- }
48962
- const sockets2 = [];
48963
- for (const { ref } of this.socketChildren.values()) {
48964
- sockets2.push(ref);
48965
- }
48966
- return { channels: channels2, subchannels: subchannels2, sockets: sockets2 };
49788
+ return {
49789
+ channels: this.channelChildren,
49790
+ subchannels: this.subchannelChildren,
49791
+ sockets: this.socketChildren
49792
+ };
48967
49793
  }
48968
49794
  };
48969
49795
  exports2.ChannelzChildrenTracker = ChannelzChildrenTracker;
49796
+ var ChannelzChildrenTrackerStub = class extends ChannelzChildrenTracker {
49797
+ refChild() {
49798
+ }
49799
+ unrefChild() {
49800
+ }
49801
+ };
49802
+ exports2.ChannelzChildrenTrackerStub = ChannelzChildrenTrackerStub;
48970
49803
  var ChannelzCallTracker = class {
48971
49804
  constructor() {
48972
49805
  this.callsStarted = 0;
@@ -48986,65 +49819,66 @@ var require_channelz = __commonJS({
48986
49819
  }
48987
49820
  };
48988
49821
  exports2.ChannelzCallTracker = ChannelzCallTracker;
48989
- var nextId = 1;
48990
- function getNextId() {
48991
- return nextId++;
48992
- }
48993
- var channels = [];
48994
- var subchannels = [];
48995
- var servers = [];
48996
- var sockets = [];
48997
- function registerChannelzChannel(name2, getInfo, channelzEnabled) {
48998
- const id = getNextId();
48999
- const ref = { id, name: name2, kind: "channel" };
49000
- if (channelzEnabled) {
49001
- channels[id] = { ref, getInfo };
49002
- }
49003
- return ref;
49004
- }
49005
- exports2.registerChannelzChannel = registerChannelzChannel;
49006
- function registerChannelzSubchannel(name2, getInfo, channelzEnabled) {
49007
- const id = getNextId();
49008
- const ref = { id, name: name2, kind: "subchannel" };
49009
- if (channelzEnabled) {
49010
- subchannels[id] = { ref, getInfo };
49011
- }
49012
- return ref;
49013
- }
49014
- exports2.registerChannelzSubchannel = registerChannelzSubchannel;
49015
- function registerChannelzServer(getInfo, channelzEnabled) {
49016
- const id = getNextId();
49017
- const ref = { id, kind: "server" };
49018
- if (channelzEnabled) {
49019
- servers[id] = { ref, getInfo };
49020
- }
49021
- return ref;
49022
- }
49023
- exports2.registerChannelzServer = registerChannelzServer;
49024
- function registerChannelzSocket(name2, getInfo, channelzEnabled) {
49025
- const id = getNextId();
49026
- const ref = { id, name: name2, kind: "socket" };
49027
- if (channelzEnabled) {
49028
- sockets[id] = { ref, getInfo };
49029
- }
49030
- return ref;
49031
- }
49032
- exports2.registerChannelzSocket = registerChannelzSocket;
49033
- function unregisterChannelzRef(ref) {
49034
- switch (ref.kind) {
49035
- case "channel":
49036
- delete channels[ref.id];
49037
- return;
49038
- case "subchannel":
49039
- delete subchannels[ref.id];
49040
- return;
49041
- case "server":
49042
- delete servers[ref.id];
49043
- return;
49044
- case "socket":
49045
- delete sockets[ref.id];
49046
- return;
49822
+ var ChannelzCallTrackerStub = class extends ChannelzCallTracker {
49823
+ addCallStarted() {
49824
+ }
49825
+ addCallSucceeded() {
49826
+ }
49827
+ addCallFailed() {
49047
49828
  }
49829
+ };
49830
+ exports2.ChannelzCallTrackerStub = ChannelzCallTrackerStub;
49831
+ var entityMaps = {
49832
+ [
49833
+ "channel"
49834
+ /* EntityTypes.channel */
49835
+ ]: new ordered_map_1.OrderedMap(),
49836
+ [
49837
+ "subchannel"
49838
+ /* EntityTypes.subchannel */
49839
+ ]: new ordered_map_1.OrderedMap(),
49840
+ [
49841
+ "server"
49842
+ /* EntityTypes.server */
49843
+ ]: new ordered_map_1.OrderedMap(),
49844
+ [
49845
+ "socket"
49846
+ /* EntityTypes.socket */
49847
+ ]: new ordered_map_1.OrderedMap()
49848
+ };
49849
+ var generateRegisterFn = (kind) => {
49850
+ let nextId = 1;
49851
+ function getNextId() {
49852
+ return nextId++;
49853
+ }
49854
+ const entityMap = entityMaps[kind];
49855
+ return (name2, getInfo, channelzEnabled) => {
49856
+ const id = getNextId();
49857
+ const ref = { id, name: name2, kind };
49858
+ if (channelzEnabled) {
49859
+ entityMap.setElement(id, { ref, getInfo });
49860
+ }
49861
+ return ref;
49862
+ };
49863
+ };
49864
+ exports2.registerChannelzChannel = generateRegisterFn(
49865
+ "channel"
49866
+ /* EntityTypes.channel */
49867
+ );
49868
+ exports2.registerChannelzSubchannel = generateRegisterFn(
49869
+ "subchannel"
49870
+ /* EntityTypes.subchannel */
49871
+ );
49872
+ exports2.registerChannelzServer = generateRegisterFn(
49873
+ "server"
49874
+ /* EntityTypes.server */
49875
+ );
49876
+ exports2.registerChannelzSocket = generateRegisterFn(
49877
+ "socket"
49878
+ /* EntityTypes.socket */
49879
+ );
49880
+ function unregisterChannelzRef(ref) {
49881
+ entityMaps[ref.kind].eraseElementByKey(ref.id);
49048
49882
  }
49049
49883
  exports2.unregisterChannelzRef = unregisterChannelzRef;
49050
49884
  function parseIPv6Section(addressSection) {
@@ -49121,6 +49955,14 @@ var require_channelz = __commonJS({
49121
49955
  }
49122
49956
  function getChannelMessage(channelEntry) {
49123
49957
  const resolvedInfo = channelEntry.getInfo();
49958
+ const channelRef = [];
49959
+ const subchannelRef = [];
49960
+ resolvedInfo.children.channels.forEach((el) => {
49961
+ channelRef.push(channelRefToMessage(el[1].ref));
49962
+ });
49963
+ resolvedInfo.children.subchannels.forEach((el) => {
49964
+ subchannelRef.push(subchannelRefToMessage(el[1].ref));
49965
+ });
49124
49966
  return {
49125
49967
  ref: channelRefToMessage(channelEntry.ref),
49126
49968
  data: {
@@ -49132,13 +49974,16 @@ var require_channelz = __commonJS({
49132
49974
  last_call_started_timestamp: dateToProtoTimestamp(resolvedInfo.callTracker.lastCallStartedTimestamp),
49133
49975
  trace: resolvedInfo.trace.getTraceMessage()
49134
49976
  },
49135
- channel_ref: resolvedInfo.children.channels.map((ref) => channelRefToMessage(ref)),
49136
- subchannel_ref: resolvedInfo.children.subchannels.map((ref) => subchannelRefToMessage(ref))
49977
+ channel_ref: channelRef,
49978
+ subchannel_ref: subchannelRef
49137
49979
  };
49138
49980
  }
49139
49981
  function GetChannel(call, callback) {
49140
- const channelId = Number.parseInt(call.request.channel_id);
49141
- const channelEntry = channels[channelId];
49982
+ const channelId = parseInt(call.request.channel_id, 10);
49983
+ const channelEntry = entityMaps[
49984
+ "channel"
49985
+ /* EntityTypes.channel */
49986
+ ].getElementByKey(channelId);
49142
49987
  if (channelEntry === void 0) {
49143
49988
  callback({
49144
49989
  code: constants_1.Status.NOT_FOUND,
@@ -49149,26 +49994,28 @@ var require_channelz = __commonJS({
49149
49994
  callback(null, { channel: getChannelMessage(channelEntry) });
49150
49995
  }
49151
49996
  function GetTopChannels(call, callback) {
49152
- const maxResults = Number.parseInt(call.request.max_results);
49997
+ const maxResults = parseInt(call.request.max_results, 10) || DEFAULT_MAX_RESULTS;
49153
49998
  const resultList = [];
49154
- let i = Number.parseInt(call.request.start_channel_id);
49155
- for (; i < channels.length; i++) {
49156
- const channelEntry = channels[i];
49157
- if (channelEntry === void 0) {
49158
- continue;
49159
- }
49160
- resultList.push(getChannelMessage(channelEntry));
49161
- if (resultList.length >= maxResults) {
49162
- break;
49163
- }
49999
+ const startId = parseInt(call.request.start_channel_id, 10);
50000
+ const channelEntries = entityMaps[
50001
+ "channel"
50002
+ /* EntityTypes.channel */
50003
+ ];
50004
+ let i;
50005
+ for (i = channelEntries.lowerBound(startId); !i.equals(channelEntries.end()) && resultList.length < maxResults; i = i.next()) {
50006
+ resultList.push(getChannelMessage(i.pointer[1]));
49164
50007
  }
49165
50008
  callback(null, {
49166
50009
  channel: resultList,
49167
- end: i >= servers.length
50010
+ end: i.equals(channelEntries.end())
49168
50011
  });
49169
50012
  }
49170
50013
  function getServerMessage(serverEntry) {
49171
50014
  const resolvedInfo = serverEntry.getInfo();
50015
+ const listenSocket = [];
50016
+ resolvedInfo.listenerChildren.sockets.forEach((el) => {
50017
+ listenSocket.push(socketRefToMessage(el[1].ref));
50018
+ });
49172
50019
  return {
49173
50020
  ref: serverRefToMessage(serverEntry.ref),
49174
50021
  data: {
@@ -49178,12 +50025,16 @@ var require_channelz = __commonJS({
49178
50025
  last_call_started_timestamp: dateToProtoTimestamp(resolvedInfo.callTracker.lastCallStartedTimestamp),
49179
50026
  trace: resolvedInfo.trace.getTraceMessage()
49180
50027
  },
49181
- listen_socket: resolvedInfo.listenerChildren.sockets.map((ref) => socketRefToMessage(ref))
50028
+ listen_socket: listenSocket
49182
50029
  };
49183
50030
  }
49184
50031
  function GetServer(call, callback) {
49185
- const serverId = Number.parseInt(call.request.server_id);
49186
- const serverEntry = servers[serverId];
50032
+ const serverId = parseInt(call.request.server_id, 10);
50033
+ const serverEntries = entityMaps[
50034
+ "server"
50035
+ /* EntityTypes.server */
50036
+ ];
50037
+ const serverEntry = serverEntries.getElementByKey(serverId);
49187
50038
  if (serverEntry === void 0) {
49188
50039
  callback({
49189
50040
  code: constants_1.Status.NOT_FOUND,
@@ -49194,27 +50045,28 @@ var require_channelz = __commonJS({
49194
50045
  callback(null, { server: getServerMessage(serverEntry) });
49195
50046
  }
49196
50047
  function GetServers(call, callback) {
49197
- const maxResults = Number.parseInt(call.request.max_results);
50048
+ const maxResults = parseInt(call.request.max_results, 10) || DEFAULT_MAX_RESULTS;
50049
+ const startId = parseInt(call.request.start_server_id, 10);
50050
+ const serverEntries = entityMaps[
50051
+ "server"
50052
+ /* EntityTypes.server */
50053
+ ];
49198
50054
  const resultList = [];
49199
- let i = Number.parseInt(call.request.start_server_id);
49200
- for (; i < servers.length; i++) {
49201
- const serverEntry = servers[i];
49202
- if (serverEntry === void 0) {
49203
- continue;
49204
- }
49205
- resultList.push(getServerMessage(serverEntry));
49206
- if (resultList.length >= maxResults) {
49207
- break;
49208
- }
50055
+ let i;
50056
+ for (i = serverEntries.lowerBound(startId); !i.equals(serverEntries.end()) && resultList.length < maxResults; i = i.next()) {
50057
+ resultList.push(getServerMessage(i.pointer[1]));
49209
50058
  }
49210
50059
  callback(null, {
49211
50060
  server: resultList,
49212
- end: i >= servers.length
50061
+ end: i.equals(serverEntries.end())
49213
50062
  });
49214
50063
  }
49215
50064
  function GetSubchannel(call, callback) {
49216
- const subchannelId = Number.parseInt(call.request.subchannel_id);
49217
- const subchannelEntry = subchannels[subchannelId];
50065
+ const subchannelId = parseInt(call.request.subchannel_id, 10);
50066
+ const subchannelEntry = entityMaps[
50067
+ "subchannel"
50068
+ /* EntityTypes.subchannel */
50069
+ ].getElementByKey(subchannelId);
49218
50070
  if (subchannelEntry === void 0) {
49219
50071
  callback({
49220
50072
  code: constants_1.Status.NOT_FOUND,
@@ -49223,6 +50075,10 @@ var require_channelz = __commonJS({
49223
50075
  return;
49224
50076
  }
49225
50077
  const resolvedInfo = subchannelEntry.getInfo();
50078
+ const listenSocket = [];
50079
+ resolvedInfo.children.sockets.forEach((el) => {
50080
+ listenSocket.push(socketRefToMessage(el[1].ref));
50081
+ });
49226
50082
  const subchannelMessage = {
49227
50083
  ref: subchannelRefToMessage(subchannelEntry.ref),
49228
50084
  data: {
@@ -49234,7 +50090,7 @@ var require_channelz = __commonJS({
49234
50090
  last_call_started_timestamp: dateToProtoTimestamp(resolvedInfo.callTracker.lastCallStartedTimestamp),
49235
50091
  trace: resolvedInfo.trace.getTraceMessage()
49236
50092
  },
49237
- socket_ref: resolvedInfo.children.sockets.map((ref) => socketRefToMessage(ref))
50093
+ socket_ref: listenSocket
49238
50094
  };
49239
50095
  callback(null, { subchannel: subchannelMessage });
49240
50096
  }
@@ -49259,8 +50115,11 @@ var require_channelz = __commonJS({
49259
50115
  }
49260
50116
  function GetSocket(call, callback) {
49261
50117
  var _a, _b, _c, _d, _e;
49262
- const socketId = Number.parseInt(call.request.socket_id);
49263
- const socketEntry = sockets[socketId];
50118
+ const socketId = parseInt(call.request.socket_id, 10);
50119
+ const socketEntry = entityMaps[
50120
+ "socket"
50121
+ /* EntityTypes.socket */
50122
+ ].getElementByKey(socketId);
49264
50123
  if (socketEntry === void 0) {
49265
50124
  callback({
49266
50125
  code: constants_1.Status.NOT_FOUND,
@@ -49303,8 +50162,11 @@ var require_channelz = __commonJS({
49303
50162
  callback(null, { socket: socketMessage });
49304
50163
  }
49305
50164
  function GetServerSockets(call, callback) {
49306
- const serverId = Number.parseInt(call.request.server_id);
49307
- const serverEntry = servers[serverId];
50165
+ const serverId = parseInt(call.request.server_id, 10);
50166
+ const serverEntry = entityMaps[
50167
+ "server"
50168
+ /* EntityTypes.server */
50169
+ ].getElementByKey(serverId);
49308
50170
  if (serverEntry === void 0) {
49309
50171
  callback({
49310
50172
  code: constants_1.Status.NOT_FOUND,
@@ -49312,23 +50174,18 @@ var require_channelz = __commonJS({
49312
50174
  });
49313
50175
  return;
49314
50176
  }
49315
- const startId = Number.parseInt(call.request.start_socket_id);
49316
- const maxResults = Number.parseInt(call.request.max_results);
50177
+ const startId = parseInt(call.request.start_socket_id, 10);
50178
+ const maxResults = parseInt(call.request.max_results, 10) || DEFAULT_MAX_RESULTS;
49317
50179
  const resolvedInfo = serverEntry.getInfo();
49318
- const allSockets = resolvedInfo.sessionChildren.sockets.sort((ref1, ref2) => ref1.id - ref2.id);
50180
+ const allSockets = resolvedInfo.sessionChildren.sockets;
49319
50181
  const resultList = [];
49320
- let i = 0;
49321
- for (; i < allSockets.length; i++) {
49322
- if (allSockets[i].id >= startId) {
49323
- resultList.push(socketRefToMessage(allSockets[i]));
49324
- if (resultList.length >= maxResults) {
49325
- break;
49326
- }
49327
- }
50182
+ let i;
50183
+ for (i = allSockets.lowerBound(startId); !i.equals(allSockets.end()) && resultList.length < maxResults; i = i.next()) {
50184
+ resultList.push(socketRefToMessage(i.pointer[1].ref));
49328
50185
  }
49329
50186
  callback(null, {
49330
50187
  socket_ref: resultList,
49331
- end: i >= allSockets.length
50188
+ end: i.equals(allSockets.end())
49332
50189
  });
49333
50190
  }
49334
50191
  function getChannelzHandlers() {
@@ -49408,9 +50265,6 @@ var require_subchannel = __commonJS({
49408
50265
  this.stateListeners = /* @__PURE__ */ new Set();
49409
50266
  this.refcount = 0;
49410
50267
  this.channelzEnabled = true;
49411
- this.callTracker = new channelz_1.ChannelzCallTracker();
49412
- this.childrenTracker = new channelz_1.ChannelzChildrenTracker();
49413
- this.streamTracker = new channelz_1.ChannelzCallTracker();
49414
50268
  const backoffOptions = {
49415
50269
  initialDelay: options["grpc.initial_reconnect_backoff_ms"],
49416
50270
  maxDelay: options["grpc.max_reconnect_backoff_ms"]
@@ -49423,12 +50277,18 @@ var require_subchannel = __commonJS({
49423
50277
  this.keepaliveTime = (_a = options["grpc.keepalive_time_ms"]) !== null && _a !== void 0 ? _a : -1;
49424
50278
  if (options["grpc.enable_channelz"] === 0) {
49425
50279
  this.channelzEnabled = false;
50280
+ this.channelzTrace = new channelz_1.ChannelzTraceStub();
50281
+ this.callTracker = new channelz_1.ChannelzCallTrackerStub();
50282
+ this.childrenTracker = new channelz_1.ChannelzChildrenTrackerStub();
50283
+ this.streamTracker = new channelz_1.ChannelzCallTrackerStub();
50284
+ } else {
50285
+ this.channelzTrace = new channelz_1.ChannelzTrace();
50286
+ this.callTracker = new channelz_1.ChannelzCallTracker();
50287
+ this.childrenTracker = new channelz_1.ChannelzChildrenTracker();
50288
+ this.streamTracker = new channelz_1.ChannelzCallTracker();
49426
50289
  }
49427
- this.channelzTrace = new channelz_1.ChannelzTrace();
49428
50290
  this.channelzRef = (0, channelz_1.registerChannelzSubchannel)(this.subchannelAddressString, () => this.getChannelzInfo(), this.channelzEnabled);
49429
- if (this.channelzEnabled) {
49430
- this.channelzTrace.addTrace("CT_INFO", "Subchannel created");
49431
- }
50291
+ this.channelzTrace.addTrace("CT_INFO", "Subchannel created");
49432
50292
  this.trace("Subchannel constructed with options " + JSON.stringify(options, void 0, 2));
49433
50293
  }
49434
50294
  getChannelzInfo() {
@@ -49551,12 +50411,8 @@ var require_subchannel = __commonJS({
49551
50411
  this.refTrace("refcount " + this.refcount + " -> " + (this.refcount - 1));
49552
50412
  this.refcount -= 1;
49553
50413
  if (this.refcount === 0) {
49554
- if (this.channelzEnabled) {
49555
- this.channelzTrace.addTrace("CT_INFO", "Shutting down");
49556
- }
49557
- if (this.channelzEnabled) {
49558
- (0, channelz_1.unregisterChannelzRef)(this.channelzRef);
49559
- }
50414
+ this.channelzTrace.addTrace("CT_INFO", "Shutting down");
50415
+ (0, channelz_1.unregisterChannelzRef)(this.channelzRef);
49560
50416
  process.nextTick(() => {
49561
50417
  this.transitionToState([connectivity_state_1.ConnectivityState.CONNECTING, connectivity_state_1.ConnectivityState.READY], connectivity_state_1.ConnectivityState.IDLE);
49562
50418
  });
@@ -49666,6 +50522,17 @@ var require_subchannel = __commonJS({
49666
50522
  }
49667
50523
  });
49668
50524
 
50525
+ // node_modules/@grpc/grpc-js/build/src/environment.js
50526
+ var require_environment13 = __commonJS({
50527
+ "node_modules/@grpc/grpc-js/build/src/environment.js"(exports2) {
50528
+ "use strict";
50529
+ var _a;
50530
+ Object.defineProperty(exports2, "__esModule", { value: true });
50531
+ exports2.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = void 0;
50532
+ exports2.GRPC_NODE_USE_ALTERNATIVE_RESOLVER = ((_a = process.env.GRPC_NODE_USE_ALTERNATIVE_RESOLVER) !== null && _a !== void 0 ? _a : "false") === "true";
50533
+ }
50534
+ });
50535
+
49669
50536
  // node_modules/@grpc/grpc-js/build/src/resolver-dns.js
49670
50537
  var require_resolver_dns = __commonJS({
49671
50538
  "node_modules/@grpc/grpc-js/build/src/resolver-dns.js"(exports2) {
@@ -49673,8 +50540,7 @@ var require_resolver_dns = __commonJS({
49673
50540
  Object.defineProperty(exports2, "__esModule", { value: true });
49674
50541
  exports2.setup = exports2.DEFAULT_PORT = void 0;
49675
50542
  var resolver_1 = require_resolver();
49676
- var dns = __require("dns");
49677
- var util = __require("util");
50543
+ var dns_1 = __require("dns");
49678
50544
  var service_config_1 = require_service_config();
49679
50545
  var constants_1 = require_constants8();
49680
50546
  var metadata_1 = require_metadata();
@@ -49683,14 +50549,13 @@ var require_resolver_dns = __commonJS({
49683
50549
  var uri_parser_1 = require_uri_parser();
49684
50550
  var net_1 = __require("net");
49685
50551
  var backoff_timeout_1 = require_backoff_timeout();
50552
+ var environment_1 = require_environment13();
49686
50553
  var TRACER_NAME = "dns_resolver";
49687
50554
  function trace(text) {
49688
50555
  logging.trace(constants_2.LogVerbosity.DEBUG, TRACER_NAME, text);
49689
50556
  }
49690
50557
  exports2.DEFAULT_PORT = 443;
49691
50558
  var DEFAULT_MIN_TIME_BETWEEN_RESOLUTIONS_MS = 3e4;
49692
- var resolveTxtPromise = util.promisify(dns.resolveTxt);
49693
- var dnsLookupPromise = util.promisify(dns.lookup);
49694
50559
  var DnsResolver = class {
49695
50560
  constructor(target, listener, channelOptions) {
49696
50561
  var _a, _b, _c;
@@ -49705,7 +50570,11 @@ var require_resolver_dns = __commonJS({
49705
50570
  this.isNextResolutionTimerRunning = false;
49706
50571
  this.isServiceConfigEnabled = true;
49707
50572
  this.returnedIpResult = false;
50573
+ this.alternativeResolver = new dns_1.promises.Resolver();
49708
50574
  trace("Resolver constructed for target " + (0, uri_parser_1.uriToString)(target));
50575
+ if (target.authority) {
50576
+ this.alternativeResolver.setServers([target.authority]);
50577
+ }
49709
50578
  const hostPort = (0, uri_parser_1.splitHostPort)(target.path);
49710
50579
  if (hostPort === null) {
49711
50580
  this.ipResult = null;
@@ -49790,7 +50659,7 @@ var require_resolver_dns = __commonJS({
49790
50659
  trace("Looking up DNS hostname " + this.dnsHostname);
49791
50660
  this.latestLookupResult = null;
49792
50661
  const hostname = this.dnsHostname;
49793
- this.pendingLookupPromise = dnsLookupPromise(hostname, { all: true });
50662
+ this.pendingLookupPromise = this.lookup(hostname);
49794
50663
  this.pendingLookupPromise.then((addressList) => {
49795
50664
  if (this.pendingLookupPromise === null) {
49796
50665
  return;
@@ -49798,11 +50667,10 @@ var require_resolver_dns = __commonJS({
49798
50667
  this.pendingLookupPromise = null;
49799
50668
  this.backoff.reset();
49800
50669
  this.backoff.stop();
49801
- const subchannelAddresses = addressList.map((addr) => ({ host: addr.address, port: +this.port }));
49802
- this.latestLookupResult = subchannelAddresses.map((address) => ({
50670
+ this.latestLookupResult = addressList.map((address) => ({
49803
50671
  addresses: [address]
49804
50672
  }));
49805
- const allAddressesString = "[" + subchannelAddresses.map((addr) => addr.host + ":" + addr.port).join(",") + "]";
50673
+ const allAddressesString = "[" + addressList.map((addr) => addr.host + ":" + addr.port).join(",") + "]";
49806
50674
  trace("Resolved addresses for target " + (0, uri_parser_1.uriToString)(this.target) + ": " + allAddressesString);
49807
50675
  if (this.latestLookupResult.length === 0) {
49808
50676
  this.listener.onError(this.defaultResolutionError);
@@ -49819,7 +50687,7 @@ var require_resolver_dns = __commonJS({
49819
50687
  this.listener.onError(this.defaultResolutionError);
49820
50688
  });
49821
50689
  if (this.isServiceConfigEnabled && this.pendingTxtPromise === null) {
49822
- this.pendingTxtPromise = resolveTxtPromise(hostname);
50690
+ this.pendingTxtPromise = this.resolveTxt(hostname);
49823
50691
  this.pendingTxtPromise.then((txtRecord) => {
49824
50692
  if (this.pendingTxtPromise === null) {
49825
50693
  return;
@@ -49842,15 +50710,43 @@ var require_resolver_dns = __commonJS({
49842
50710
  }
49843
50711
  }
49844
50712
  }
50713
+ async lookup(hostname) {
50714
+ if (environment_1.GRPC_NODE_USE_ALTERNATIVE_RESOLVER) {
50715
+ trace("Using alternative DNS resolver.");
50716
+ const records = await Promise.allSettled([
50717
+ this.alternativeResolver.resolve4(hostname),
50718
+ this.alternativeResolver.resolve6(hostname)
50719
+ ]);
50720
+ if (records.every((result) => result.status === "rejected")) {
50721
+ throw new Error(records[0].reason);
50722
+ }
50723
+ return records.reduce((acc, result) => {
50724
+ return result.status === "fulfilled" ? [...acc, ...result.value] : acc;
50725
+ }, []).map((addr) => ({
50726
+ host: addr,
50727
+ port: +this.port
50728
+ }));
50729
+ }
50730
+ const addressList = await dns_1.promises.lookup(hostname, { all: true });
50731
+ return addressList.map((addr) => ({ host: addr.address, port: +this.port }));
50732
+ }
50733
+ async resolveTxt(hostname) {
50734
+ if (environment_1.GRPC_NODE_USE_ALTERNATIVE_RESOLVER) {
50735
+ trace("Using alternative DNS resolver.");
50736
+ return this.alternativeResolver.resolveTxt(hostname);
50737
+ }
50738
+ return dns_1.promises.resolveTxt(hostname);
50739
+ }
49845
50740
  startNextResolutionTimer() {
49846
50741
  var _a, _b;
49847
50742
  clearTimeout(this.nextResolutionTimer);
49848
- this.nextResolutionTimer = (_b = (_a = setTimeout(() => {
50743
+ this.nextResolutionTimer = setTimeout(() => {
49849
50744
  this.stopNextResolutionTimer();
49850
50745
  if (this.continueResolving) {
49851
50746
  this.startResolutionWithBackoff();
49852
50747
  }
49853
- }, this.minTimeBetweenResolutionsMs)).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
50748
+ }, this.minTimeBetweenResolutionsMs);
50749
+ (_b = (_a = this.nextResolutionTimer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
49854
50750
  this.isNextResolutionTimerRunning = true;
49855
50751
  }
49856
50752
  stopNextResolutionTimer() {
@@ -49963,7 +50859,7 @@ var require_http_proxy = __commonJS({
49963
50859
  if (proxyUrl.username) {
49964
50860
  if (proxyUrl.password) {
49965
50861
  (0, logging_1.log)(constants_1.LogVerbosity.INFO, "userinfo found in proxy URI");
49966
- userCred = `${proxyUrl.username}:${proxyUrl.password}`;
50862
+ userCred = decodeURIComponent(`${proxyUrl.username}:${proxyUrl.password}`);
49967
50863
  } else {
49968
50864
  userCred = proxyUrl.username;
49969
50865
  }
@@ -50080,6 +50976,9 @@ var require_http_proxy = __commonJS({
50080
50976
  socket.removeAllListeners();
50081
50977
  if (res.statusCode === 200) {
50082
50978
  trace("Successfully connected to " + options.path + " through proxy " + proxyAddressString);
50979
+ if (head.length > 0) {
50980
+ socket.unshift(head);
50981
+ }
50083
50982
  if ("secureContext" in connectionOptions) {
50084
50983
  const targetPath = (0, resolver_1.getDefaultAuthority)(parsedTarget);
50085
50984
  const hostPort2 = (0, uri_parser_1.splitHostPort)(targetPath);
@@ -50129,7 +51028,8 @@ var require_stream_decoder = __commonJS({
50129
51028
  ReadState2[ReadState2["READING_MESSAGE"] = 2] = "READING_MESSAGE";
50130
51029
  })(ReadState || (ReadState = {}));
50131
51030
  var StreamDecoder = class {
50132
- constructor() {
51031
+ constructor(maxReadMessageLength) {
51032
+ this.maxReadMessageLength = maxReadMessageLength;
50133
51033
  this.readState = ReadState.NO_DATA;
50134
51034
  this.readCompressFlag = Buffer.alloc(1);
50135
51035
  this.readPartialSize = Buffer.alloc(4);
@@ -50161,6 +51061,9 @@ var require_stream_decoder = __commonJS({
50161
51061
  readHead += toRead;
50162
51062
  if (this.readSizeRemaining === 0) {
50163
51063
  this.readMessageSize = this.readPartialSize.readUInt32BE(0);
51064
+ if (this.maxReadMessageLength !== -1 && this.readMessageSize > this.maxReadMessageLength) {
51065
+ throw new Error(`Received message larger than max (${this.readMessageSize} vs ${this.maxReadMessageLength})`);
51066
+ }
50164
51067
  this.readMessageRemaining = this.readMessageSize;
50165
51068
  if (this.readMessageRemaining > 0) {
50166
51069
  this.readState = ReadState.READING_MESSAGE;
@@ -50219,51 +51122,64 @@ var require_subchannel_call = __commonJS({
50219
51122
  }
50220
51123
  return "Unknown system error " + errno;
50221
51124
  }
51125
+ function mapHttpStatusCode(code) {
51126
+ const details = `Received HTTP status code ${code}`;
51127
+ let mappedStatusCode;
51128
+ switch (code) {
51129
+ // TODO(murgatroid99): handle 100 and 101
51130
+ case 400:
51131
+ mappedStatusCode = constants_1.Status.INTERNAL;
51132
+ break;
51133
+ case 401:
51134
+ mappedStatusCode = constants_1.Status.UNAUTHENTICATED;
51135
+ break;
51136
+ case 403:
51137
+ mappedStatusCode = constants_1.Status.PERMISSION_DENIED;
51138
+ break;
51139
+ case 404:
51140
+ mappedStatusCode = constants_1.Status.UNIMPLEMENTED;
51141
+ break;
51142
+ case 429:
51143
+ case 502:
51144
+ case 503:
51145
+ case 504:
51146
+ mappedStatusCode = constants_1.Status.UNAVAILABLE;
51147
+ break;
51148
+ default:
51149
+ mappedStatusCode = constants_1.Status.UNKNOWN;
51150
+ }
51151
+ return {
51152
+ code: mappedStatusCode,
51153
+ details,
51154
+ metadata: new metadata_1.Metadata()
51155
+ };
51156
+ }
50222
51157
  var Http2SubchannelCall = class {
50223
51158
  constructor(http2Stream, callEventTracker, listener, transport, callId) {
51159
+ var _a;
50224
51160
  this.http2Stream = http2Stream;
50225
51161
  this.callEventTracker = callEventTracker;
50226
51162
  this.listener = listener;
50227
51163
  this.transport = transport;
50228
51164
  this.callId = callId;
50229
- this.decoder = new stream_decoder_1.StreamDecoder();
50230
51165
  this.isReadFilterPending = false;
50231
51166
  this.isPushPending = false;
50232
51167
  this.canPush = false;
50233
51168
  this.readsClosed = false;
50234
51169
  this.statusOutput = false;
50235
51170
  this.unpushedReadMessages = [];
50236
- this.mappedStatusCode = constants_1.Status.UNKNOWN;
50237
51171
  this.finalStatus = null;
50238
51172
  this.internalError = null;
51173
+ this.serverEndedCall = false;
51174
+ const maxReceiveMessageLength = (_a = transport.getOptions()["grpc.max_receive_message_length"]) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH;
51175
+ this.decoder = new stream_decoder_1.StreamDecoder(maxReceiveMessageLength);
50239
51176
  http2Stream.on("response", (headers, flags) => {
50240
51177
  let headersString = "";
50241
51178
  for (const header of Object.keys(headers)) {
50242
51179
  headersString += " " + header + ": " + headers[header] + "\n";
50243
51180
  }
50244
51181
  this.trace("Received server headers:\n" + headersString);
50245
- switch (headers[":status"]) {
50246
- case 400:
50247
- this.mappedStatusCode = constants_1.Status.INTERNAL;
50248
- break;
50249
- case 401:
50250
- this.mappedStatusCode = constants_1.Status.UNAUTHENTICATED;
50251
- break;
50252
- case 403:
50253
- this.mappedStatusCode = constants_1.Status.PERMISSION_DENIED;
50254
- break;
50255
- case 404:
50256
- this.mappedStatusCode = constants_1.Status.UNIMPLEMENTED;
50257
- break;
50258
- case 429:
50259
- case 502:
50260
- case 503:
50261
- case 504:
50262
- this.mappedStatusCode = constants_1.Status.UNAVAILABLE;
50263
- break;
50264
- default:
50265
- this.mappedStatusCode = constants_1.Status.UNKNOWN;
50266
- }
51182
+ this.httpStatusCode = headers[":status"];
50267
51183
  if (flags & http2.constants.NGHTTP2_FLAG_END_STREAM) {
50268
51184
  this.handleTrailers(headers);
50269
51185
  } else {
@@ -50289,7 +51205,13 @@ var require_subchannel_call = __commonJS({
50289
51205
  return;
50290
51206
  }
50291
51207
  this.trace("receive HTTP/2 data frame of length " + data.length);
50292
- const messages = this.decoder.write(data);
51208
+ let messages;
51209
+ try {
51210
+ messages = this.decoder.write(data);
51211
+ } catch (e) {
51212
+ this.cancelWithStatus(constants_1.Status.RESOURCE_EXHAUSTED, e.message);
51213
+ return;
51214
+ }
50293
51215
  for (const message of messages) {
50294
51216
  this.trace("parsed message of length " + message.length);
50295
51217
  this.callEventTracker.addMessageReceived();
@@ -50301,10 +51223,11 @@ var require_subchannel_call = __commonJS({
50301
51223
  this.maybeOutputStatus();
50302
51224
  });
50303
51225
  http2Stream.on("close", () => {
51226
+ this.serverEndedCall = true;
50304
51227
  process.nextTick(() => {
50305
- var _a;
51228
+ var _a2;
50306
51229
  this.trace("HTTP/2 stream closed with code " + http2Stream.rstCode);
50307
- if (((_a = this.finalStatus) === null || _a === void 0 ? void 0 : _a.code) === constants_1.Status.OK) {
51230
+ if (((_a2 = this.finalStatus) === null || _a2 === void 0 ? void 0 : _a2.code) === constants_1.Status.OK) {
50308
51231
  return;
50309
51232
  }
50310
51233
  let code;
@@ -50314,8 +51237,14 @@ var require_subchannel_call = __commonJS({
50314
51237
  if (this.finalStatus !== null) {
50315
51238
  return;
50316
51239
  }
50317
- code = constants_1.Status.INTERNAL;
50318
- details = `Received RST_STREAM with code ${http2Stream.rstCode}`;
51240
+ if (this.httpStatusCode && this.httpStatusCode !== 200) {
51241
+ const mappedStatus = mapHttpStatusCode(this.httpStatusCode);
51242
+ code = mappedStatus.code;
51243
+ details = mappedStatus.details;
51244
+ } else {
51245
+ code = constants_1.Status.INTERNAL;
51246
+ details = `Received RST_STREAM with code ${http2Stream.rstCode} (Call ended without gRPC status)`;
51247
+ }
50319
51248
  break;
50320
51249
  case http2.constants.NGHTTP2_REFUSED_STREAM:
50321
51250
  code = constants_1.Status.UNAVAILABLE;
@@ -50366,6 +51295,9 @@ var require_subchannel_call = __commonJS({
50366
51295
  this.callEventTracker.onStreamEnd(false);
50367
51296
  });
50368
51297
  }
51298
+ getDeadlineInfo() {
51299
+ return [`remote_addr=${this.getPeer()}`];
51300
+ }
50369
51301
  onDisconnect() {
50370
51302
  this.endCall({
50371
51303
  code: constants_1.Status.UNAVAILABLE,
@@ -50429,6 +51361,7 @@ var require_subchannel_call = __commonJS({
50429
51361
  }
50430
51362
  }
50431
51363
  handleTrailers(headers) {
51364
+ this.serverEndedCall = true;
50432
51365
  this.callEventTracker.onStreamEnd(true);
50433
51366
  let headersString = "";
50434
51367
  for (const header of Object.keys(headers)) {
@@ -50442,31 +51375,46 @@ var require_subchannel_call = __commonJS({
50442
51375
  metadata = new metadata_1.Metadata();
50443
51376
  }
50444
51377
  const metadataMap = metadata.getMap();
50445
- let code = this.mappedStatusCode;
50446
- if (code === constants_1.Status.UNKNOWN && typeof metadataMap["grpc-status"] === "string") {
51378
+ let status;
51379
+ if (typeof metadataMap["grpc-status"] === "string") {
50447
51380
  const receivedStatus = Number(metadataMap["grpc-status"]);
50448
- if (receivedStatus in constants_1.Status) {
50449
- code = receivedStatus;
50450
- this.trace("received status code " + receivedStatus + " from server");
50451
- }
51381
+ this.trace("received status code " + receivedStatus + " from server");
50452
51382
  metadata.remove("grpc-status");
50453
- }
50454
- let details = "";
50455
- if (typeof metadataMap["grpc-message"] === "string") {
50456
- try {
50457
- details = decodeURI(metadataMap["grpc-message"]);
50458
- } catch (e) {
50459
- details = metadataMap["grpc-message"];
51383
+ let details = "";
51384
+ if (typeof metadataMap["grpc-message"] === "string") {
51385
+ try {
51386
+ details = decodeURI(metadataMap["grpc-message"]);
51387
+ } catch (e) {
51388
+ details = metadataMap["grpc-message"];
51389
+ }
51390
+ metadata.remove("grpc-message");
51391
+ this.trace('received status details string "' + details + '" from server');
50460
51392
  }
50461
- metadata.remove("grpc-message");
50462
- this.trace('received status details string "' + details + '" from server');
51393
+ status = {
51394
+ code: receivedStatus,
51395
+ details,
51396
+ metadata
51397
+ };
51398
+ } else if (this.httpStatusCode) {
51399
+ status = mapHttpStatusCode(this.httpStatusCode);
51400
+ status.metadata = metadata;
51401
+ } else {
51402
+ status = {
51403
+ code: constants_1.Status.UNKNOWN,
51404
+ details: "No status information received",
51405
+ metadata
51406
+ };
50463
51407
  }
50464
- const status = { code, details, metadata };
50465
51408
  this.endCall(status);
50466
51409
  }
50467
51410
  destroyHttp2Stream() {
50468
51411
  var _a;
50469
- if (!this.http2Stream.destroyed) {
51412
+ if (this.http2Stream.destroyed) {
51413
+ return;
51414
+ }
51415
+ if (this.serverEndedCall) {
51416
+ this.http2Stream.end();
51417
+ } else {
50470
51418
  let code;
50471
51419
  if (((_a = this.finalStatus) === null || _a === void 0 ? void 0 : _a.code) === constants_1.Status.OK) {
50472
51420
  code = http2.constants.NGHTTP2_NO_ERROR;
@@ -50582,18 +51530,14 @@ var require_transport = __commonJS({
50582
51530
  var Http2Transport = class {
50583
51531
  constructor(session, subchannelAddress, options, remoteName) {
50584
51532
  this.session = session;
51533
+ this.options = options;
50585
51534
  this.remoteName = remoteName;
50586
- this.keepaliveTimeMs = -1;
50587
- this.keepaliveTimeoutMs = KEEPALIVE_TIMEOUT_MS;
50588
- this.keepaliveTimerId = null;
51535
+ this.keepaliveTimer = null;
50589
51536
  this.pendingSendKeepalivePing = false;
50590
- this.keepaliveTimeoutId = null;
50591
- this.keepaliveWithoutCalls = false;
50592
51537
  this.activeCalls = /* @__PURE__ */ new Set();
50593
51538
  this.disconnectListeners = [];
50594
51539
  this.disconnectHandled = false;
50595
51540
  this.channelzEnabled = true;
50596
- this.streamTracker = new channelz_1.ChannelzCallTracker();
50597
51541
  this.keepalivesSent = 0;
50598
51542
  this.messagesSent = 0;
50599
51543
  this.messagesReceived = 0;
@@ -50602,6 +51546,9 @@ var require_transport = __commonJS({
50602
51546
  this.subchannelAddressString = (0, subchannel_address_1.subchannelAddressToString)(subchannelAddress);
50603
51547
  if (options["grpc.enable_channelz"] === 0) {
50604
51548
  this.channelzEnabled = false;
51549
+ this.streamTracker = new channelz_1.ChannelzCallTrackerStub();
51550
+ } else {
51551
+ this.streamTracker = new channelz_1.ChannelzCallTracker();
50605
51552
  }
50606
51553
  this.channelzRef = (0, channelz_1.registerChannelzSocket)(this.subchannelAddressString, () => this.getChannelzInfo(), this.channelzEnabled);
50607
51554
  this.userAgent = [
@@ -50611,9 +51558,13 @@ var require_transport = __commonJS({
50611
51558
  ].filter((e) => e).join(" ");
50612
51559
  if ("grpc.keepalive_time_ms" in options) {
50613
51560
  this.keepaliveTimeMs = options["grpc.keepalive_time_ms"];
51561
+ } else {
51562
+ this.keepaliveTimeMs = -1;
50614
51563
  }
50615
51564
  if ("grpc.keepalive_timeout_ms" in options) {
50616
51565
  this.keepaliveTimeoutMs = options["grpc.keepalive_timeout_ms"];
51566
+ } else {
51567
+ this.keepaliveTimeoutMs = KEEPALIVE_TIMEOUT_MS;
50617
51568
  }
50618
51569
  if ("grpc.keepalive_permit_without_calls" in options) {
50619
51570
  this.keepaliveWithoutCalls = options["grpc.keepalive_permit_without_calls"] === 1;
@@ -50622,7 +51573,6 @@ var require_transport = __commonJS({
50622
51573
  }
50623
51574
  session.once("close", () => {
50624
51575
  this.trace("session closed");
50625
- this.stopKeepalivePings();
50626
51576
  this.handleDisconnect();
50627
51577
  });
50628
51578
  session.once("goaway", (errorCode, lastStreamID, opaqueData) => {
@@ -50635,6 +51585,7 @@ var require_transport = __commonJS({
50635
51585
  });
50636
51586
  session.once("error", (error) => {
50637
51587
  this.trace("connection closed with error " + error.message);
51588
+ this.handleDisconnect();
50638
51589
  });
50639
51590
  if (logging.isTracerEnabled(TRACER_NAME)) {
50640
51591
  session.on("remoteSettings", (settings) => {
@@ -50720,62 +51671,64 @@ var require_transport = __commonJS({
50720
51671
  * Handle connection drops, but not GOAWAYs.
50721
51672
  */
50722
51673
  handleDisconnect() {
51674
+ if (this.disconnectHandled) {
51675
+ return;
51676
+ }
51677
+ this.clearKeepaliveTimeout();
50723
51678
  this.reportDisconnectToOwner(false);
50724
51679
  setImmediate(() => {
50725
51680
  for (const call of this.activeCalls) {
50726
51681
  call.onDisconnect();
50727
51682
  }
51683
+ this.session.destroy();
50728
51684
  });
50729
51685
  }
50730
51686
  addDisconnectListener(listener) {
50731
51687
  this.disconnectListeners.push(listener);
50732
51688
  }
50733
- clearKeepaliveTimer() {
50734
- if (!this.keepaliveTimerId) {
50735
- return;
50736
- }
50737
- clearTimeout(this.keepaliveTimerId);
50738
- this.keepaliveTimerId = null;
50739
- }
50740
- clearKeepaliveTimeout() {
50741
- if (!this.keepaliveTimeoutId) {
50742
- return;
50743
- }
50744
- clearTimeout(this.keepaliveTimeoutId);
50745
- this.keepaliveTimeoutId = null;
50746
- }
50747
51689
  canSendPing() {
50748
- return this.keepaliveTimeMs > 0 && (this.keepaliveWithoutCalls || this.activeCalls.size > 0);
51690
+ return !this.session.destroyed && this.keepaliveTimeMs > 0 && (this.keepaliveWithoutCalls || this.activeCalls.size > 0);
50749
51691
  }
50750
51692
  maybeSendPing() {
50751
51693
  var _a, _b;
50752
- this.clearKeepaliveTimer();
50753
51694
  if (!this.canSendPing()) {
50754
51695
  this.pendingSendKeepalivePing = true;
50755
51696
  return;
50756
51697
  }
51698
+ if (this.keepaliveTimer) {
51699
+ console.error("keepaliveTimeout is not null");
51700
+ return;
51701
+ }
50757
51702
  if (this.channelzEnabled) {
50758
51703
  this.keepalivesSent += 1;
50759
51704
  }
50760
51705
  this.keepaliveTrace("Sending ping with timeout " + this.keepaliveTimeoutMs + "ms");
50761
- if (!this.keepaliveTimeoutId) {
50762
- this.keepaliveTimeoutId = setTimeout(() => {
50763
- this.keepaliveTrace("Ping timeout passed without response");
50764
- this.handleDisconnect();
50765
- }, this.keepaliveTimeoutMs);
50766
- (_b = (_a = this.keepaliveTimeoutId).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
50767
- }
51706
+ this.keepaliveTimer = setTimeout(() => {
51707
+ this.keepaliveTimer = null;
51708
+ this.keepaliveTrace("Ping timeout passed without response");
51709
+ this.handleDisconnect();
51710
+ }, this.keepaliveTimeoutMs);
51711
+ (_b = (_a = this.keepaliveTimer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
51712
+ let pingSendError = "";
50768
51713
  try {
50769
- this.session.ping((err, duration, payload) => {
51714
+ const pingSentSuccessfully = this.session.ping((err, duration, payload) => {
51715
+ this.clearKeepaliveTimeout();
50770
51716
  if (err) {
50771
51717
  this.keepaliveTrace("Ping failed with error " + err.message);
50772
51718
  this.handleDisconnect();
51719
+ } else {
51720
+ this.keepaliveTrace("Received ping response");
51721
+ this.maybeStartKeepalivePingTimer();
50773
51722
  }
50774
- this.keepaliveTrace("Received ping response");
50775
- this.clearKeepaliveTimeout();
50776
- this.maybeStartKeepalivePingTimer();
50777
51723
  });
51724
+ if (!pingSentSuccessfully) {
51725
+ pingSendError = "Ping returned false";
51726
+ }
50778
51727
  } catch (e) {
51728
+ pingSendError = (e instanceof Error ? e.message : "") || "Unknown error";
51729
+ }
51730
+ if (pingSendError) {
51731
+ this.keepaliveTrace("Ping send failed: " + pingSendError);
50779
51732
  this.handleDisconnect();
50780
51733
  }
50781
51734
  }
@@ -50793,19 +51746,23 @@ var require_transport = __commonJS({
50793
51746
  if (this.pendingSendKeepalivePing) {
50794
51747
  this.pendingSendKeepalivePing = false;
50795
51748
  this.maybeSendPing();
50796
- } else if (!this.keepaliveTimerId && !this.keepaliveTimeoutId) {
51749
+ } else if (!this.keepaliveTimer) {
50797
51750
  this.keepaliveTrace("Starting keepalive timer for " + this.keepaliveTimeMs + "ms");
50798
- this.keepaliveTimerId = (_b = (_a = setTimeout(() => {
51751
+ this.keepaliveTimer = setTimeout(() => {
51752
+ this.keepaliveTimer = null;
50799
51753
  this.maybeSendPing();
50800
- }, this.keepaliveTimeMs)).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
51754
+ }, this.keepaliveTimeMs);
51755
+ (_b = (_a = this.keepaliveTimer).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
50801
51756
  }
50802
51757
  }
50803
- stopKeepalivePings() {
50804
- if (this.keepaliveTimerId) {
50805
- clearTimeout(this.keepaliveTimerId);
50806
- this.keepaliveTimerId = null;
51758
+ /**
51759
+ * Clears whichever keepalive timeout is currently active, if any.
51760
+ */
51761
+ clearKeepaliveTimeout() {
51762
+ if (this.keepaliveTimer) {
51763
+ clearTimeout(this.keepaliveTimer);
51764
+ this.keepaliveTimer = null;
50807
51765
  }
50808
- this.clearKeepaliveTimeout();
50809
51766
  }
50810
51767
  removeActiveCall(call) {
50811
51768
  this.activeCalls.delete(call);
@@ -50902,6 +51859,9 @@ var require_transport = __commonJS({
50902
51859
  getPeerName() {
50903
51860
  return this.subchannelAddressString;
50904
51861
  }
51862
+ getOptions() {
51863
+ return this.options;
51864
+ }
50905
51865
  shutdown() {
50906
51866
  this.session.close();
50907
51867
  (0, channelz_1.unregisterChannelzRef)(this.channelzRef);
@@ -50921,7 +51881,7 @@ var require_transport = __commonJS({
50921
51881
  return Promise.reject();
50922
51882
  }
50923
51883
  return new Promise((resolve, reject) => {
50924
- var _a, _b, _c;
51884
+ var _a, _b, _c, _d;
50925
51885
  let remoteName;
50926
51886
  if (proxyConnectionResult.realTarget) {
50927
51887
  remoteName = (0, uri_parser_1.uriToString)(proxyConnectionResult.realTarget);
@@ -50943,12 +51903,13 @@ var require_transport = __commonJS({
50943
51903
  addressScheme = "https://";
50944
51904
  if (options["grpc.ssl_target_name_override"]) {
50945
51905
  const sslTargetNameOverride = options["grpc.ssl_target_name_override"];
51906
+ const originalCheckServerIdentity = (_b = connectionOptions.checkServerIdentity) !== null && _b !== void 0 ? _b : tls_1.checkServerIdentity;
50946
51907
  connectionOptions.checkServerIdentity = (host, cert) => {
50947
- return (0, tls_1.checkServerIdentity)(sslTargetNameOverride, cert);
51908
+ return originalCheckServerIdentity(sslTargetNameOverride, cert);
50948
51909
  };
50949
51910
  connectionOptions.servername = sslTargetNameOverride;
50950
51911
  } else {
50951
- const authorityHostname = (_c = (_b = (0, uri_parser_1.splitHostPort)(targetAuthority)) === null || _b === void 0 ? void 0 : _b.host) !== null && _c !== void 0 ? _c : "localhost";
51912
+ const authorityHostname = (_d = (_c = (0, uri_parser_1.splitHostPort)(targetAuthority)) === null || _c === void 0 ? void 0 : _c.host) !== null && _d !== void 0 ? _d : "localhost";
50952
51913
  connectionOptions.servername = authorityHostname;
50953
51914
  }
50954
51915
  if (proxyConnectionResult.socket) {
@@ -50969,6 +51930,7 @@ var require_transport = __commonJS({
50969
51930
  const session = http2.connect(addressScheme + targetAuthority, connectionOptions);
50970
51931
  this.session = session;
50971
51932
  let errorMessage = "Failed to connect";
51933
+ let reportedError = false;
50972
51934
  session.unref();
50973
51935
  session.once("connect", () => {
50974
51936
  session.removeAllListeners();
@@ -50978,17 +51940,24 @@ var require_transport = __commonJS({
50978
51940
  session.once("close", () => {
50979
51941
  this.session = null;
50980
51942
  setImmediate(() => {
50981
- reject(`${errorMessage} (${(/* @__PURE__ */ new Date()).toISOString()})`);
51943
+ if (!reportedError) {
51944
+ reportedError = true;
51945
+ reject(`${errorMessage} (${(/* @__PURE__ */ new Date()).toISOString()})`);
51946
+ }
50982
51947
  });
50983
51948
  });
50984
51949
  session.once("error", (error) => {
50985
51950
  errorMessage = error.message;
50986
51951
  this.trace("connection failed with error " + errorMessage);
51952
+ if (!reportedError) {
51953
+ reportedError = true;
51954
+ reject(`${errorMessage} (${(/* @__PURE__ */ new Date()).toISOString()})`);
51955
+ }
50987
51956
  });
50988
51957
  });
50989
51958
  }
50990
51959
  connect(address, credentials, options) {
50991
- var _a, _b;
51960
+ var _a, _b, _c;
50992
51961
  if (this.isShutdown) {
50993
51962
  return Promise.reject();
50994
51963
  }
@@ -50997,17 +51966,18 @@ var require_transport = __commonJS({
50997
51966
  connectionOptions.ALPNProtocols = ["h2"];
50998
51967
  if (options["grpc.ssl_target_name_override"]) {
50999
51968
  const sslTargetNameOverride = options["grpc.ssl_target_name_override"];
51969
+ const originalCheckServerIdentity = (_a = connectionOptions.checkServerIdentity) !== null && _a !== void 0 ? _a : tls_1.checkServerIdentity;
51000
51970
  connectionOptions.checkServerIdentity = (host, cert) => {
51001
- return (0, tls_1.checkServerIdentity)(sslTargetNameOverride, cert);
51971
+ return originalCheckServerIdentity(sslTargetNameOverride, cert);
51002
51972
  };
51003
51973
  connectionOptions.servername = sslTargetNameOverride;
51004
51974
  } else {
51005
51975
  if ("grpc.http_connect_target" in options) {
51006
- const targetPath = (0, resolver_1.getDefaultAuthority)((_a = (0, uri_parser_1.parseUri)(options["grpc.http_connect_target"])) !== null && _a !== void 0 ? _a : {
51976
+ const targetPath = (0, resolver_1.getDefaultAuthority)((_b = (0, uri_parser_1.parseUri)(options["grpc.http_connect_target"])) !== null && _b !== void 0 ? _b : {
51007
51977
  path: "localhost"
51008
51978
  });
51009
51979
  const hostPort = (0, uri_parser_1.splitHostPort)(targetPath);
51010
- connectionOptions.servername = (_b = hostPort === null || hostPort === void 0 ? void 0 : hostPort.host) !== null && _b !== void 0 ? _b : targetPath;
51980
+ connectionOptions.servername = (_c = hostPort === null || hostPort === void 0 ? void 0 : hostPort.host) !== null && _c !== void 0 ? _c : targetPath;
51011
51981
  }
51012
51982
  }
51013
51983
  if (options["grpc-node.tls_enable_trace"]) {
@@ -51298,6 +52268,10 @@ var require_compression_filter = __commonJS({
51298
52268
  }
51299
52269
  };
51300
52270
  var DeflateHandler = class extends CompressionHandler {
52271
+ constructor(maxRecvMessageLength) {
52272
+ super();
52273
+ this.maxRecvMessageLength = maxRecvMessageLength;
52274
+ }
51301
52275
  compressMessage(message) {
51302
52276
  return new Promise((resolve, reject) => {
51303
52277
  zlib.deflate(message, (err, output) => {
@@ -51311,17 +52285,33 @@ var require_compression_filter = __commonJS({
51311
52285
  }
51312
52286
  decompressMessage(message) {
51313
52287
  return new Promise((resolve, reject) => {
51314
- zlib.inflate(message, (err, output) => {
51315
- if (err) {
51316
- reject(err);
51317
- } else {
51318
- resolve(output);
52288
+ let totalLength = 0;
52289
+ const messageParts = [];
52290
+ const decompresser = zlib.createInflate();
52291
+ decompresser.on("data", (chunk) => {
52292
+ messageParts.push(chunk);
52293
+ totalLength += chunk.byteLength;
52294
+ if (this.maxRecvMessageLength !== -1 && totalLength > this.maxRecvMessageLength) {
52295
+ decompresser.destroy();
52296
+ reject({
52297
+ code: constants_1.Status.RESOURCE_EXHAUSTED,
52298
+ details: `Received message that decompresses to a size larger than ${this.maxRecvMessageLength}`
52299
+ });
51319
52300
  }
51320
52301
  });
52302
+ decompresser.on("end", () => {
52303
+ resolve(Buffer.concat(messageParts));
52304
+ });
52305
+ decompresser.write(message);
52306
+ decompresser.end();
51321
52307
  });
51322
52308
  }
51323
52309
  };
51324
52310
  var GzipHandler = class extends CompressionHandler {
52311
+ constructor(maxRecvMessageLength) {
52312
+ super();
52313
+ this.maxRecvMessageLength = maxRecvMessageLength;
52314
+ }
51325
52315
  compressMessage(message) {
51326
52316
  return new Promise((resolve, reject) => {
51327
52317
  zlib.gzip(message, (err, output) => {
@@ -51335,13 +52325,25 @@ var require_compression_filter = __commonJS({
51335
52325
  }
51336
52326
  decompressMessage(message) {
51337
52327
  return new Promise((resolve, reject) => {
51338
- zlib.unzip(message, (err, output) => {
51339
- if (err) {
51340
- reject(err);
51341
- } else {
51342
- resolve(output);
52328
+ let totalLength = 0;
52329
+ const messageParts = [];
52330
+ const decompresser = zlib.createGunzip();
52331
+ decompresser.on("data", (chunk) => {
52332
+ messageParts.push(chunk);
52333
+ totalLength += chunk.byteLength;
52334
+ if (this.maxRecvMessageLength !== -1 && totalLength > this.maxRecvMessageLength) {
52335
+ decompresser.destroy();
52336
+ reject({
52337
+ code: constants_1.Status.RESOURCE_EXHAUSTED,
52338
+ details: `Received message that decompresses to a size larger than ${this.maxRecvMessageLength}`
52339
+ });
51343
52340
  }
51344
52341
  });
52342
+ decompresser.on("end", () => {
52343
+ resolve(Buffer.concat(messageParts));
52344
+ });
52345
+ decompresser.write(message);
52346
+ decompresser.end();
51345
52347
  });
51346
52348
  }
51347
52349
  };
@@ -51357,34 +52359,36 @@ var require_compression_filter = __commonJS({
51357
52359
  return Promise.reject(new Error(`Compression method not supported: ${this.compressionName}`));
51358
52360
  }
51359
52361
  };
51360
- function getCompressionHandler(compressionName) {
52362
+ function getCompressionHandler(compressionName, maxReceiveMessageSize) {
51361
52363
  switch (compressionName) {
51362
52364
  case "identity":
51363
52365
  return new IdentityHandler();
51364
52366
  case "deflate":
51365
- return new DeflateHandler();
52367
+ return new DeflateHandler(maxReceiveMessageSize);
51366
52368
  case "gzip":
51367
- return new GzipHandler();
52369
+ return new GzipHandler(maxReceiveMessageSize);
51368
52370
  default:
51369
52371
  return new UnknownHandler(compressionName);
51370
52372
  }
51371
52373
  }
51372
52374
  var CompressionFilter = class extends filter_1.BaseFilter {
51373
52375
  constructor(channelOptions, sharedFilterConfig) {
51374
- var _a;
52376
+ var _a, _b, _c;
51375
52377
  super();
51376
52378
  this.sharedFilterConfig = sharedFilterConfig;
51377
52379
  this.sendCompression = new IdentityHandler();
51378
52380
  this.receiveCompression = new IdentityHandler();
51379
52381
  this.currentCompressionAlgorithm = "identity";
51380
52382
  const compressionAlgorithmKey = channelOptions["grpc.default_compression_algorithm"];
52383
+ this.maxReceiveMessageLength = (_a = channelOptions["grpc.max_receive_message_length"]) !== null && _a !== void 0 ? _a : constants_1.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH;
52384
+ this.maxSendMessageLength = (_b = channelOptions["grpc.max_send_message_length"]) !== null && _b !== void 0 ? _b : constants_1.DEFAULT_MAX_SEND_MESSAGE_LENGTH;
51381
52385
  if (compressionAlgorithmKey !== void 0) {
51382
52386
  if (isCompressionAlgorithmKey(compressionAlgorithmKey)) {
51383
52387
  const clientSelectedEncoding = compression_algorithms_1.CompressionAlgorithms[compressionAlgorithmKey];
51384
- const serverSupportedEncodings = (_a = sharedFilterConfig.serverSupportedEncodingHeader) === null || _a === void 0 ? void 0 : _a.split(",");
52388
+ const serverSupportedEncodings = (_c = sharedFilterConfig.serverSupportedEncodingHeader) === null || _c === void 0 ? void 0 : _c.split(",");
51385
52389
  if (!serverSupportedEncodings || serverSupportedEncodings.includes(clientSelectedEncoding)) {
51386
52390
  this.currentCompressionAlgorithm = clientSelectedEncoding;
51387
- this.sendCompression = getCompressionHandler(this.currentCompressionAlgorithm);
52391
+ this.sendCompression = getCompressionHandler(this.currentCompressionAlgorithm, -1);
51388
52392
  }
51389
52393
  } else {
51390
52394
  logging.log(constants_1.LogVerbosity.ERROR, `Invalid value provided for grpc.default_compression_algorithm option: ${compressionAlgorithmKey}`);
@@ -51407,7 +52411,7 @@ var require_compression_filter = __commonJS({
51407
52411
  if (receiveEncoding.length > 0) {
51408
52412
  const encoding = receiveEncoding[0];
51409
52413
  if (typeof encoding === "string") {
51410
- this.receiveCompression = getCompressionHandler(encoding);
52414
+ this.receiveCompression = getCompressionHandler(encoding, this.maxReceiveMessageLength);
51411
52415
  }
51412
52416
  }
51413
52417
  metadata.remove("grpc-encoding");
@@ -51426,6 +52430,12 @@ var require_compression_filter = __commonJS({
51426
52430
  async sendMessage(message) {
51427
52431
  var _a;
51428
52432
  const resolvedMessage = await message;
52433
+ if (this.maxSendMessageLength !== -1 && resolvedMessage.message.length > this.maxSendMessageLength) {
52434
+ throw {
52435
+ code: constants_1.Status.RESOURCE_EXHAUSTED,
52436
+ details: `Attempted to send message with a size larger than ${this.maxSendMessageLength}`
52437
+ };
52438
+ }
51429
52439
  let compress;
51430
52440
  if (this.sendCompression instanceof IdentityHandler) {
51431
52441
  compress = false;
@@ -51455,79 +52465,12 @@ var require_compression_filter = __commonJS({
51455
52465
  }
51456
52466
  });
51457
52467
 
51458
- // node_modules/@grpc/grpc-js/build/src/max-message-size-filter.js
51459
- var require_max_message_size_filter = __commonJS({
51460
- "node_modules/@grpc/grpc-js/build/src/max-message-size-filter.js"(exports2) {
51461
- "use strict";
51462
- Object.defineProperty(exports2, "__esModule", { value: true });
51463
- exports2.MaxMessageSizeFilterFactory = exports2.MaxMessageSizeFilter = void 0;
51464
- var filter_1 = require_filter();
51465
- var constants_1 = require_constants8();
51466
- var metadata_1 = require_metadata();
51467
- var MaxMessageSizeFilter = class extends filter_1.BaseFilter {
51468
- constructor(options) {
51469
- super();
51470
- this.maxSendMessageSize = constants_1.DEFAULT_MAX_SEND_MESSAGE_LENGTH;
51471
- this.maxReceiveMessageSize = constants_1.DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH;
51472
- if ("grpc.max_send_message_length" in options) {
51473
- this.maxSendMessageSize = options["grpc.max_send_message_length"];
51474
- }
51475
- if ("grpc.max_receive_message_length" in options) {
51476
- this.maxReceiveMessageSize = options["grpc.max_receive_message_length"];
51477
- }
51478
- }
51479
- async sendMessage(message) {
51480
- if (this.maxSendMessageSize === -1) {
51481
- return message;
51482
- } else {
51483
- const concreteMessage = await message;
51484
- if (concreteMessage.message.length > this.maxSendMessageSize) {
51485
- throw {
51486
- code: constants_1.Status.RESOURCE_EXHAUSTED,
51487
- details: `Sent message larger than max (${concreteMessage.message.length} vs. ${this.maxSendMessageSize})`,
51488
- metadata: new metadata_1.Metadata()
51489
- };
51490
- } else {
51491
- return concreteMessage;
51492
- }
51493
- }
51494
- }
51495
- async receiveMessage(message) {
51496
- if (this.maxReceiveMessageSize === -1) {
51497
- return message;
51498
- } else {
51499
- const concreteMessage = await message;
51500
- if (concreteMessage.length > this.maxReceiveMessageSize) {
51501
- throw {
51502
- code: constants_1.Status.RESOURCE_EXHAUSTED,
51503
- details: `Received message larger than max (${concreteMessage.length} vs. ${this.maxReceiveMessageSize})`,
51504
- metadata: new metadata_1.Metadata()
51505
- };
51506
- } else {
51507
- return concreteMessage;
51508
- }
51509
- }
51510
- }
51511
- };
51512
- exports2.MaxMessageSizeFilter = MaxMessageSizeFilter;
51513
- var MaxMessageSizeFilterFactory = class {
51514
- constructor(options) {
51515
- this.options = options;
51516
- }
51517
- createFilter() {
51518
- return new MaxMessageSizeFilter(this.options);
51519
- }
51520
- };
51521
- exports2.MaxMessageSizeFilterFactory = MaxMessageSizeFilterFactory;
51522
- }
51523
- });
51524
-
51525
52468
  // node_modules/@grpc/grpc-js/build/src/deadline.js
51526
52469
  var require_deadline = __commonJS({
51527
52470
  "node_modules/@grpc/grpc-js/build/src/deadline.js"(exports2) {
51528
52471
  "use strict";
51529
52472
  Object.defineProperty(exports2, "__esModule", { value: true });
51530
- exports2.deadlineToString = exports2.getRelativeTimeout = exports2.getDeadlineTimeoutString = exports2.minDeadline = void 0;
52473
+ exports2.formatDateDifference = exports2.deadlineToString = exports2.getRelativeTimeout = exports2.getDeadlineTimeoutString = exports2.minDeadline = void 0;
51531
52474
  function minDeadline(...deadlineList) {
51532
52475
  let minValue = Infinity;
51533
52476
  for (const deadline of deadlineList) {
@@ -51587,6 +52530,10 @@ var require_deadline = __commonJS({
51587
52530
  }
51588
52531
  }
51589
52532
  exports2.deadlineToString = deadlineToString;
52533
+ function formatDateDifference(startDate, endDate) {
52534
+ return ((endDate.getTime() - startDate.getTime()) / 1e3).toFixed(3) + "s";
52535
+ }
52536
+ exports2.formatDateDifference = formatDateDifference;
51590
52537
  }
51591
52538
  });
51592
52539
 
@@ -51655,6 +52602,7 @@ var require_load_balancing_call = __commonJS({
51655
52602
  this.metadata = null;
51656
52603
  this.listener = null;
51657
52604
  this.onCallEnded = null;
52605
+ this.childStartTime = null;
51658
52606
  const splitPath = this.methodName.split("/");
51659
52607
  let serviceName = "";
51660
52608
  if (splitPath.length >= 2) {
@@ -51662,6 +52610,27 @@ var require_load_balancing_call = __commonJS({
51662
52610
  }
51663
52611
  const hostname = (_b = (_a = (0, uri_parser_1.splitHostPort)(this.host)) === null || _a === void 0 ? void 0 : _a.host) !== null && _b !== void 0 ? _b : "localhost";
51664
52612
  this.serviceUrl = `https://${hostname}/${serviceName}`;
52613
+ this.startTime = /* @__PURE__ */ new Date();
52614
+ }
52615
+ getDeadlineInfo() {
52616
+ var _a, _b;
52617
+ const deadlineInfo = [];
52618
+ if (this.childStartTime) {
52619
+ if (this.childStartTime > this.startTime) {
52620
+ if ((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.getOptions().waitForReady) {
52621
+ deadlineInfo.push("wait_for_ready");
52622
+ }
52623
+ deadlineInfo.push(`LB pick: ${(0, deadline_1.formatDateDifference)(this.startTime, this.childStartTime)}`);
52624
+ }
52625
+ deadlineInfo.push(...this.child.getDeadlineInfo());
52626
+ return deadlineInfo;
52627
+ } else {
52628
+ if ((_b = this.metadata) === null || _b === void 0 ? void 0 : _b.getOptions().waitForReady) {
52629
+ deadlineInfo.push("wait_for_ready");
52630
+ }
52631
+ deadlineInfo.push("Waiting for LB pick");
52632
+ }
52633
+ return deadlineInfo;
51665
52634
  }
51666
52635
  trace(text) {
51667
52636
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text);
@@ -51670,7 +52639,7 @@ var require_load_balancing_call = __commonJS({
51670
52639
  var _a, _b;
51671
52640
  if (!this.ended) {
51672
52641
  this.ended = true;
51673
- this.trace("ended with status: code=" + status.code + ' details="' + status.details + '"');
52642
+ this.trace("ended with status: code=" + status.code + ' details="' + status.details + '" start time=' + this.startTime.toISOString());
51674
52643
  const finalStatus = Object.assign(Object.assign({}, status), { progress });
51675
52644
  (_a = this.listener) === null || _a === void 0 ? void 0 : _a.onReceiveStatus(finalStatus);
51676
52645
  (_b = this.onCallEnded) === null || _b === void 0 ? void 0 : _b.call(this, finalStatus.code);
@@ -51732,6 +52701,7 @@ var require_load_balancing_call = __commonJS({
51732
52701
  }
51733
52702
  }
51734
52703
  });
52704
+ this.childStartTime = /* @__PURE__ */ new Date();
51735
52705
  } catch (error) {
51736
52706
  this.trace("Failed to start call on picked subchannel " + subchannelString + " with error " + error.message);
51737
52707
  this.outputStatus({
@@ -51867,6 +52837,9 @@ var require_resolving_call = __commonJS({
51867
52837
  this.deadlineTimer = setTimeout(() => {
51868
52838
  }, 0);
51869
52839
  this.filterStack = null;
52840
+ this.deadlineStartTime = null;
52841
+ this.configReceivedTime = null;
52842
+ this.childStartTime = null;
51870
52843
  this.deadline = options.deadline;
51871
52844
  this.host = options.host;
51872
52845
  if (options.parentCall) {
@@ -51888,12 +52861,37 @@ var require_resolving_call = __commonJS({
51888
52861
  }
51889
52862
  runDeadlineTimer() {
51890
52863
  clearTimeout(this.deadlineTimer);
52864
+ this.deadlineStartTime = /* @__PURE__ */ new Date();
51891
52865
  this.trace("Deadline: " + (0, deadline_1.deadlineToString)(this.deadline));
51892
52866
  const timeout = (0, deadline_1.getRelativeTimeout)(this.deadline);
51893
52867
  if (timeout !== Infinity) {
51894
52868
  this.trace("Deadline will be reached in " + timeout + "ms");
51895
52869
  const handleDeadline = () => {
51896
- this.cancelWithStatus(constants_1.Status.DEADLINE_EXCEEDED, "Deadline exceeded");
52870
+ if (!this.deadlineStartTime) {
52871
+ this.cancelWithStatus(constants_1.Status.DEADLINE_EXCEEDED, "Deadline exceeded");
52872
+ return;
52873
+ }
52874
+ const deadlineInfo = [];
52875
+ const deadlineEndTime = /* @__PURE__ */ new Date();
52876
+ deadlineInfo.push(`Deadline exceeded after ${(0, deadline_1.formatDateDifference)(this.deadlineStartTime, deadlineEndTime)}`);
52877
+ if (this.configReceivedTime) {
52878
+ if (this.configReceivedTime > this.deadlineStartTime) {
52879
+ deadlineInfo.push(`name resolution: ${(0, deadline_1.formatDateDifference)(this.deadlineStartTime, this.configReceivedTime)}`);
52880
+ }
52881
+ if (this.childStartTime) {
52882
+ if (this.childStartTime > this.configReceivedTime) {
52883
+ deadlineInfo.push(`metadata filters: ${(0, deadline_1.formatDateDifference)(this.configReceivedTime, this.childStartTime)}`);
52884
+ }
52885
+ } else {
52886
+ deadlineInfo.push("waiting for metadata filters");
52887
+ }
52888
+ } else {
52889
+ deadlineInfo.push("waiting for name resolution");
52890
+ }
52891
+ if (this.child) {
52892
+ deadlineInfo.push(...this.child.getDeadlineInfo());
52893
+ }
52894
+ this.cancelWithStatus(constants_1.Status.DEADLINE_EXCEEDED, deadlineInfo.join(","));
51897
52895
  };
51898
52896
  if (timeout <= 0) {
51899
52897
  process.nextTick(handleDeadline);
@@ -51953,6 +52951,7 @@ var require_resolving_call = __commonJS({
51953
52951
  }
51954
52952
  return;
51955
52953
  }
52954
+ this.configReceivedTime = /* @__PURE__ */ new Date();
51956
52955
  const config = configResult.config;
51957
52956
  if (config.status !== constants_1.Status.OK) {
51958
52957
  const { code, details } = (0, control_plane_status_1.restrictControlPlaneStatusCode)(config.status, "Failed to route call to method " + this.method);
@@ -51975,6 +52974,7 @@ var require_resolving_call = __commonJS({
51975
52974
  this.filterStack.sendMetadata(Promise.resolve(this.metadata)).then((filteredMetadata) => {
51976
52975
  this.child = this.channel.createInnerCall(config, this.method, this.host, this.credentials, this.deadline);
51977
52976
  this.trace("Created child [" + this.child.getCallNumber() + "]");
52977
+ this.childStartTime = /* @__PURE__ */ new Date();
51978
52978
  this.child.start(filteredMetadata, {
51979
52979
  onReceiveMetadata: (metadata) => {
51980
52980
  this.trace("Received metadata");
@@ -52088,6 +53088,7 @@ var require_retrying_call = __commonJS({
52088
53088
  Object.defineProperty(exports2, "__esModule", { value: true });
52089
53089
  exports2.RetryingCall = exports2.MessageBufferTracker = exports2.RetryThrottler = void 0;
52090
53090
  var constants_1 = require_constants8();
53091
+ var deadline_1 = require_deadline();
52091
53092
  var metadata_1 = require_metadata();
52092
53093
  var logging = require_logging();
52093
53094
  var TRACER_NAME = "retrying_call";
@@ -52153,8 +53154,10 @@ var require_retrying_call = __commonJS({
52153
53154
  };
52154
53155
  exports2.MessageBufferTracker = MessageBufferTracker;
52155
53156
  var PREVIONS_RPC_ATTEMPTS_METADATA_KEY = "grpc-previous-rpc-attempts";
53157
+ var DEFAULT_MAX_ATTEMPTS_LIMIT = 5;
52156
53158
  var RetryingCall = class {
52157
53159
  constructor(channel, callConfig, methodName, host, credentials, deadline, callNumber, bufferTracker, retryThrottler) {
53160
+ var _a;
52158
53161
  this.channel = channel;
52159
53162
  this.callConfig = callConfig;
52160
53163
  this.methodName = methodName;
@@ -52176,15 +53179,35 @@ var require_retrying_call = __commonJS({
52176
53179
  this.committedCallIndex = null;
52177
53180
  this.initialRetryBackoffSec = 0;
52178
53181
  this.nextRetryBackoffSec = 0;
53182
+ const maxAttemptsLimit = (_a = channel.getOptions()["grpc-node.retry_max_attempts_limit"]) !== null && _a !== void 0 ? _a : DEFAULT_MAX_ATTEMPTS_LIMIT;
52179
53183
  if (callConfig.methodConfig.retryPolicy) {
52180
53184
  this.state = "RETRY";
52181
53185
  const retryPolicy = callConfig.methodConfig.retryPolicy;
52182
53186
  this.nextRetryBackoffSec = this.initialRetryBackoffSec = Number(retryPolicy.initialBackoff.substring(0, retryPolicy.initialBackoff.length - 1));
53187
+ this.maxAttempts = Math.min(retryPolicy.maxAttempts, maxAttemptsLimit);
52183
53188
  } else if (callConfig.methodConfig.hedgingPolicy) {
52184
53189
  this.state = "HEDGING";
53190
+ this.maxAttempts = Math.min(callConfig.methodConfig.hedgingPolicy.maxAttempts, maxAttemptsLimit);
52185
53191
  } else {
52186
53192
  this.state = "TRANSPARENT_ONLY";
53193
+ this.maxAttempts = 1;
52187
53194
  }
53195
+ this.startTime = /* @__PURE__ */ new Date();
53196
+ }
53197
+ getDeadlineInfo() {
53198
+ if (this.underlyingCalls.length === 0) {
53199
+ return [];
53200
+ }
53201
+ const deadlineInfo = [];
53202
+ const latestCall = this.underlyingCalls[this.underlyingCalls.length - 1];
53203
+ if (this.underlyingCalls.length > 1) {
53204
+ deadlineInfo.push(`previous attempts: ${this.underlyingCalls.length - 1}`);
53205
+ }
53206
+ if (latestCall.startTime > this.startTime) {
53207
+ deadlineInfo.push(`time to current attempt start: ${(0, deadline_1.formatDateDifference)(this.startTime, latestCall.startTime)}`);
53208
+ }
53209
+ deadlineInfo.push(...latestCall.call.getDeadlineInfo());
53210
+ return deadlineInfo;
52188
53211
  }
52189
53212
  getCallNumber() {
52190
53213
  return this.callNumber;
@@ -52193,7 +53216,7 @@ var require_retrying_call = __commonJS({
52193
53216
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "[" + this.callNumber + "] " + text);
52194
53217
  }
52195
53218
  reportStatus(statusObject) {
52196
- this.trace("ended with status: code=" + statusObject.code + ' details="' + statusObject.details + '"');
53219
+ this.trace("ended with status: code=" + statusObject.code + ' details="' + statusObject.details + '" start time=' + this.startTime.toISOString());
52197
53220
  this.bufferTracker.freeAll(this.callNumber);
52198
53221
  this.writeBufferOffset = this.writeBufferOffset + this.writeBuffer.length;
52199
53222
  this.writeBuffer = [];
@@ -52285,7 +53308,10 @@ var require_retrying_call = __commonJS({
52285
53308
  }
52286
53309
  }
52287
53310
  isStatusCodeInList(list, code) {
52288
- return list.some((value) => value === code || value.toString().toLowerCase() === constants_1.Status[code].toLowerCase());
53311
+ return list.some((value) => {
53312
+ var _a;
53313
+ return value === code || value.toString().toLowerCase() === ((_a = constants_1.Status[code]) === null || _a === void 0 ? void 0 : _a.toLowerCase());
53314
+ });
52289
53315
  }
52290
53316
  getNextRetryBackoffMs() {
52291
53317
  var _a;
@@ -52303,8 +53329,7 @@ var require_retrying_call = __commonJS({
52303
53329
  callback(false);
52304
53330
  return;
52305
53331
  }
52306
- const retryPolicy = this.callConfig.methodConfig.retryPolicy;
52307
- if (this.attempts >= Math.min(retryPolicy.maxAttempts, 5)) {
53332
+ if (this.attempts >= this.maxAttempts) {
52308
53333
  callback(false);
52309
53334
  return;
52310
53335
  }
@@ -52448,8 +53473,7 @@ var require_retrying_call = __commonJS({
52448
53473
  if (!this.callConfig.methodConfig.hedgingPolicy) {
52449
53474
  return;
52450
53475
  }
52451
- const hedgingPolicy = this.callConfig.methodConfig.hedgingPolicy;
52452
- if (this.attempts >= Math.min(hedgingPolicy.maxAttempts, 5)) {
53476
+ if (this.attempts >= this.maxAttempts) {
52453
53477
  return;
52454
53478
  }
52455
53479
  this.attempts += 1;
@@ -52468,7 +53492,7 @@ var require_retrying_call = __commonJS({
52468
53492
  return;
52469
53493
  }
52470
53494
  const hedgingPolicy = this.callConfig.methodConfig.hedgingPolicy;
52471
- if (this.attempts >= Math.min(hedgingPolicy.maxAttempts, 5)) {
53495
+ if (this.attempts >= this.maxAttempts) {
52472
53496
  return;
52473
53497
  }
52474
53498
  const hedgingDelayString = (_a = hedgingPolicy.hedgingDelay) !== null && _a !== void 0 ? _a : "0s";
@@ -52485,7 +53509,8 @@ var require_retrying_call = __commonJS({
52485
53509
  this.underlyingCalls.push({
52486
53510
  state: "ACTIVE",
52487
53511
  call: child,
52488
- nextMessageToSend: 0
53512
+ nextMessageToSend: 0,
53513
+ startTime: /* @__PURE__ */ new Date()
52489
53514
  });
52490
53515
  const previousAttempts = this.attempts - 1;
52491
53516
  const initialMetadata = this.initialMetadata.clone();
@@ -52731,12 +53756,12 @@ var require_internal_channel = __commonJS({
52731
53756
  var resolving_load_balancer_1 = require_resolving_load_balancer();
52732
53757
  var subchannel_pool_1 = require_subchannel_pool();
52733
53758
  var picker_1 = require_picker();
53759
+ var metadata_1 = require_metadata();
52734
53760
  var constants_1 = require_constants8();
52735
53761
  var filter_stack_1 = require_filter_stack();
52736
53762
  var compression_filter_1 = require_compression_filter();
52737
53763
  var resolver_1 = require_resolver();
52738
53764
  var logging_1 = require_logging();
52739
- var max_message_size_filter_1 = require_max_message_size_filter();
52740
53765
  var http_proxy_1 = require_http_proxy();
52741
53766
  var uri_parser_1 = require_uri_parser();
52742
53767
  var connectivity_state_1 = require_connectivity_state();
@@ -52777,6 +53802,21 @@ var require_internal_channel = __commonJS({
52777
53802
  }
52778
53803
  }
52779
53804
  };
53805
+ var ShutdownPicker = class {
53806
+ pick(pickArgs) {
53807
+ return {
53808
+ pickResultType: picker_1.PickResultType.DROP,
53809
+ status: {
53810
+ code: constants_1.Status.UNAVAILABLE,
53811
+ details: "Channel closed before call started",
53812
+ metadata: new metadata_1.Metadata()
53813
+ },
53814
+ subchannel: null,
53815
+ onCallStarted: null,
53816
+ onCallEnded: null
53817
+ };
53818
+ }
53819
+ };
52780
53820
  var InternalChannel = class {
52781
53821
  constructor(target, credentials, options) {
52782
53822
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -52917,12 +53957,13 @@ var require_internal_channel = __commonJS({
52917
53957
  }
52918
53958
  });
52919
53959
  this.filterStackFactory = new filter_stack_1.FilterStackFactory([
52920
- new max_message_size_filter_1.MaxMessageSizeFilterFactory(this.options),
52921
53960
  new compression_filter_1.CompressionFilterFactory(this, this.options)
52922
53961
  ]);
52923
53962
  this.trace("Channel constructed with options " + JSON.stringify(options, void 0, 2));
52924
53963
  const error = new Error();
52925
- (0, logging_1.trace)(constants_1.LogVerbosity.DEBUG, "channel_stacktrace", "(" + this.channelzRef.id + ") Channel constructed \n" + ((_h = error.stack) === null || _h === void 0 ? void 0 : _h.substring(error.stack.indexOf("\n") + 1)));
53964
+ if ((0, logging_1.isTracerEnabled)("channel_stacktrace")) {
53965
+ (0, logging_1.trace)(constants_1.LogVerbosity.DEBUG, "channel_stacktrace", "(" + this.channelzRef.id + ") Channel constructed \n" + ((_h = error.stack) === null || _h === void 0 ? void 0 : _h.substring(error.stack.indexOf("\n") + 1)));
53966
+ }
52926
53967
  this.lastActivityTimestamp = /* @__PURE__ */ new Date();
52927
53968
  }
52928
53969
  getChannelzInfo() {
@@ -52999,7 +54040,9 @@ var require_internal_channel = __commonJS({
52999
54040
  this.callRefTimerRef();
53000
54041
  }
53001
54042
  getConfig(method, metadata) {
53002
- this.resolvingLoadBalancer.exitIdle();
54043
+ if (this.connectivityState !== connectivity_state_1.ConnectivityState.SHUTDOWN) {
54044
+ this.resolvingLoadBalancer.exitIdle();
54045
+ }
53003
54046
  if (this.configSelector) {
53004
54047
  return {
53005
54048
  type: "SUCCESS",
@@ -53108,6 +54151,15 @@ var require_internal_channel = __commonJS({
53108
54151
  close() {
53109
54152
  this.resolvingLoadBalancer.destroy();
53110
54153
  this.updateState(connectivity_state_1.ConnectivityState.SHUTDOWN);
54154
+ this.currentPicker = new ShutdownPicker();
54155
+ for (const call of this.configSelectionQueue) {
54156
+ call.cancelWithStatus(constants_1.Status.UNAVAILABLE, "Channel closed before call started");
54157
+ }
54158
+ this.configSelectionQueue = [];
54159
+ for (const call of this.pickQueue) {
54160
+ call.cancelWithStatus(constants_1.Status.UNAVAILABLE, "Channel closed before call started");
54161
+ }
54162
+ this.pickQueue = [];
53111
54163
  clearInterval(this.callRefTimer);
53112
54164
  if (this.idleTimer) {
53113
54165
  clearTimeout(this.idleTimer);
@@ -53173,6 +54225,9 @@ var require_internal_channel = __commonJS({
53173
54225
  }
53174
54226
  return this.createResolvingCall(method, deadline, host, parentCall, propagateFlags);
53175
54227
  }
54228
+ getOptions() {
54229
+ return this.options;
54230
+ }
53176
54231
  };
53177
54232
  exports2.InternalChannel = InternalChannel;
53178
54233
  }
@@ -53282,6 +54337,9 @@ var require_server_call = __commonJS({
53282
54337
  getPath() {
53283
54338
  return this.path;
53284
54339
  }
54340
+ getHost() {
54341
+ return this.call.getHost();
54342
+ }
53285
54343
  };
53286
54344
  exports2.ServerUnaryCallImpl = ServerUnaryCallImpl;
53287
54345
  var ServerReadableStreamImpl = class extends stream_1.Readable {
@@ -53307,6 +54365,9 @@ var require_server_call = __commonJS({
53307
54365
  getPath() {
53308
54366
  return this.path;
53309
54367
  }
54368
+ getHost() {
54369
+ return this.call.getHost();
54370
+ }
53310
54371
  };
53311
54372
  exports2.ServerReadableStreamImpl = ServerReadableStreamImpl;
53312
54373
  var ServerWritableStreamImpl = class extends stream_1.Writable {
@@ -53339,13 +54400,16 @@ var require_server_call = __commonJS({
53339
54400
  getPath() {
53340
54401
  return this.path;
53341
54402
  }
54403
+ getHost() {
54404
+ return this.call.getHost();
54405
+ }
53342
54406
  _write(chunk, encoding, callback) {
53343
54407
  this.call.sendMessage(chunk, callback);
53344
54408
  }
53345
54409
  _final(callback) {
53346
54410
  var _a;
53347
- this.call.sendStatus(Object.assign(Object.assign({}, this.pendingStatus), { metadata: (_a = this.pendingStatus.metadata) !== null && _a !== void 0 ? _a : this.trailingMetadata }));
53348
54411
  callback(null);
54412
+ this.call.sendStatus(Object.assign(Object.assign({}, this.pendingStatus), { metadata: (_a = this.pendingStatus.metadata) !== null && _a !== void 0 ? _a : this.trailingMetadata }));
53349
54413
  }
53350
54414
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
53351
54415
  end(metadata) {
@@ -53385,6 +54449,9 @@ var require_server_call = __commonJS({
53385
54449
  getPath() {
53386
54450
  return this.path;
53387
54451
  }
54452
+ getHost() {
54453
+ return this.call.getHost();
54454
+ }
53388
54455
  _read(size) {
53389
54456
  this.call.startRead();
53390
54457
  }
@@ -53393,8 +54460,8 @@ var require_server_call = __commonJS({
53393
54460
  }
53394
54461
  _final(callback) {
53395
54462
  var _a;
53396
- this.call.sendStatus(Object.assign(Object.assign({}, this.pendingStatus), { metadata: (_a = this.pendingStatus.metadata) !== null && _a !== void 0 ? _a : this.trailingMetadata }));
53397
54463
  callback(null);
54464
+ this.call.sendStatus(Object.assign(Object.assign({}, this.pendingStatus), { metadata: (_a = this.pendingStatus.metadata) !== null && _a !== void 0 ? _a : this.trailingMetadata }));
53398
54465
  }
53399
54466
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
53400
54467
  end(metadata) {
@@ -53413,9 +54480,35 @@ var require_server_credentials = __commonJS({
53413
54480
  "node_modules/@grpc/grpc-js/build/src/server-credentials.js"(exports2) {
53414
54481
  "use strict";
53415
54482
  Object.defineProperty(exports2, "__esModule", { value: true });
53416
- exports2.ServerCredentials = void 0;
54483
+ exports2.createServerCredentialsWithInterceptors = exports2.ServerCredentials = void 0;
53417
54484
  var tls_helpers_1 = require_tls_helpers();
53418
54485
  var ServerCredentials = class {
54486
+ constructor() {
54487
+ this.watchers = /* @__PURE__ */ new Set();
54488
+ this.latestContextOptions = null;
54489
+ }
54490
+ _addWatcher(watcher) {
54491
+ this.watchers.add(watcher);
54492
+ }
54493
+ _removeWatcher(watcher) {
54494
+ this.watchers.delete(watcher);
54495
+ }
54496
+ updateSecureContextOptions(options) {
54497
+ if (options) {
54498
+ this.latestContextOptions = options;
54499
+ } else {
54500
+ this.latestContextOptions = null;
54501
+ }
54502
+ for (const watcher of this.watchers) {
54503
+ watcher(this.latestContextOptions);
54504
+ }
54505
+ }
54506
+ _getSettings() {
54507
+ return this.latestContextOptions;
54508
+ }
54509
+ _getInterceptors() {
54510
+ return [];
54511
+ }
53419
54512
  static createInsecure() {
53420
54513
  return new InsecureServerCredentials();
53421
54514
  }
@@ -53550,6 +54643,46 @@ var require_server_credentials = __commonJS({
53550
54643
  return true;
53551
54644
  }
53552
54645
  };
54646
+ var InterceptorServerCredentials = class _InterceptorServerCredentials extends ServerCredentials {
54647
+ constructor(childCredentials, interceptors) {
54648
+ super();
54649
+ this.childCredentials = childCredentials;
54650
+ this.interceptors = interceptors;
54651
+ }
54652
+ _isSecure() {
54653
+ return this.childCredentials._isSecure();
54654
+ }
54655
+ _equals(other) {
54656
+ if (!(other instanceof _InterceptorServerCredentials)) {
54657
+ return false;
54658
+ }
54659
+ if (!this.childCredentials._equals(other.childCredentials)) {
54660
+ return false;
54661
+ }
54662
+ if (this.interceptors.length !== other.interceptors.length) {
54663
+ return false;
54664
+ }
54665
+ for (let i = 0; i < this.interceptors.length; i++) {
54666
+ if (this.interceptors[i] !== other.interceptors[i]) {
54667
+ return false;
54668
+ }
54669
+ }
54670
+ return true;
54671
+ }
54672
+ _getInterceptors() {
54673
+ return this.interceptors;
54674
+ }
54675
+ _addWatcher(watcher) {
54676
+ this.childCredentials._addWatcher(watcher);
54677
+ }
54678
+ _removeWatcher(watcher) {
54679
+ this.childCredentials._removeWatcher(watcher);
54680
+ }
54681
+ };
54682
+ function createServerCredentialsWithInterceptors(credentials, interceptors) {
54683
+ return new InterceptorServerCredentials(credentials, interceptors);
54684
+ }
54685
+ exports2.createServerCredentialsWithInterceptors = createServerCredentialsWithInterceptors;
53553
54686
  }
53554
54687
  });
53555
54688
 
@@ -53564,11 +54697,8 @@ var require_server_interceptors = __commonJS({
53564
54697
  var http2 = __require("http2");
53565
54698
  var error_1 = require_error();
53566
54699
  var zlib = __require("zlib");
53567
- var util_1 = __require("util");
53568
54700
  var stream_decoder_1 = require_stream_decoder();
53569
54701
  var logging = require_logging();
53570
- var unzip = (0, util_1.promisify)(zlib.unzip);
53571
- var inflate = (0, util_1.promisify)(zlib.inflate);
53572
54702
  var TRACER_NAME = "server_call";
53573
54703
  function trace(text) {
53574
54704
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, text);
@@ -53751,13 +54881,19 @@ var require_server_interceptors = __commonJS({
53751
54881
  };
53752
54882
  var ServerInterceptingCall = class {
53753
54883
  constructor(nextCall, responder) {
54884
+ var _a, _b, _c, _d;
53754
54885
  this.nextCall = nextCall;
53755
54886
  this.processingMetadata = false;
53756
54887
  this.processingMessage = false;
53757
54888
  this.pendingMessage = null;
53758
54889
  this.pendingMessageCallback = null;
53759
54890
  this.pendingStatus = null;
53760
- this.responder = Object.assign(Object.assign({}, defaultResponder), responder);
54891
+ this.responder = {
54892
+ start: (_a = responder === null || responder === void 0 ? void 0 : responder.start) !== null && _a !== void 0 ? _a : defaultResponder.start,
54893
+ sendMetadata: (_b = responder === null || responder === void 0 ? void 0 : responder.sendMetadata) !== null && _b !== void 0 ? _b : defaultResponder.sendMetadata,
54894
+ sendMessage: (_c = responder === null || responder === void 0 ? void 0 : responder.sendMessage) !== null && _c !== void 0 ? _c : defaultResponder.sendMessage,
54895
+ sendStatus: (_d = responder === null || responder === void 0 ? void 0 : responder.sendStatus) !== null && _d !== void 0 ? _d : defaultResponder.sendStatus
54896
+ };
53761
54897
  }
53762
54898
  processPendingMessage() {
53763
54899
  if (this.pendingMessageCallback) {
@@ -53774,7 +54910,13 @@ var require_server_interceptors = __commonJS({
53774
54910
  }
53775
54911
  start(listener) {
53776
54912
  this.responder.start((interceptedListener) => {
53777
- const fullInterceptedListener = Object.assign(Object.assign({}, defaultServerListener), interceptedListener);
54913
+ var _a, _b, _c, _d;
54914
+ const fullInterceptedListener = {
54915
+ onReceiveMetadata: (_a = interceptedListener === null || interceptedListener === void 0 ? void 0 : interceptedListener.onReceiveMetadata) !== null && _a !== void 0 ? _a : defaultServerListener.onReceiveMetadata,
54916
+ onReceiveMessage: (_b = interceptedListener === null || interceptedListener === void 0 ? void 0 : interceptedListener.onReceiveMessage) !== null && _b !== void 0 ? _b : defaultServerListener.onReceiveMessage,
54917
+ onReceiveHalfClose: (_c = interceptedListener === null || interceptedListener === void 0 ? void 0 : interceptedListener.onReceiveHalfClose) !== null && _c !== void 0 ? _c : defaultServerListener.onReceiveHalfClose,
54918
+ onCancel: (_d = interceptedListener === null || interceptedListener === void 0 ? void 0 : interceptedListener.onCancel) !== null && _d !== void 0 ? _d : defaultServerListener.onCancel
54919
+ };
53778
54920
  const finalInterceptingListener = new InterceptingServerListenerImpl(fullInterceptedListener, listener);
53779
54921
  this.nextCall.start(finalInterceptingListener);
53780
54922
  });
@@ -53818,6 +54960,9 @@ var require_server_interceptors = __commonJS({
53818
54960
  getDeadline() {
53819
54961
  return this.nextCall.getDeadline();
53820
54962
  }
54963
+ getHost() {
54964
+ return this.nextCall.getHost();
54965
+ }
53821
54966
  };
53822
54967
  exports2.ServerInterceptingCall = ServerInterceptingCall;
53823
54968
  var GRPC_ACCEPT_ENCODING_HEADER = "grpc-accept-encoding";
@@ -53849,6 +54994,7 @@ var require_server_interceptors = __commonJS({
53849
54994
  };
53850
54995
  var BaseServerInterceptingCall = class {
53851
54996
  constructor(stream, headers, callEventTracker, handler, options) {
54997
+ var _a;
53852
54998
  this.stream = stream;
53853
54999
  this.callEventTracker = callEventTracker;
53854
55000
  this.handler = handler;
@@ -53862,7 +55008,6 @@ var require_server_interceptors = __commonJS({
53862
55008
  this.wantTrailers = false;
53863
55009
  this.cancelNotified = false;
53864
55010
  this.incomingEncoding = "identity";
53865
- this.decoder = new stream_decoder_1.StreamDecoder();
53866
55011
  this.readQueue = [];
53867
55012
  this.isReadPending = false;
53868
55013
  this.receivedHalfClose = false;
@@ -53870,8 +55015,8 @@ var require_server_interceptors = __commonJS({
53870
55015
  this.stream.once("error", (err) => {
53871
55016
  });
53872
55017
  this.stream.once("close", () => {
53873
- var _a;
53874
- trace("Request to method " + ((_a = this.handler) === null || _a === void 0 ? void 0 : _a.path) + " stream closed with rstCode " + this.stream.rstCode);
55018
+ var _a2;
55019
+ trace("Request to method " + ((_a2 = this.handler) === null || _a2 === void 0 ? void 0 : _a2.path) + " stream closed with rstCode " + this.stream.rstCode);
53875
55020
  if (this.callEventTracker && !this.streamEnded) {
53876
55021
  this.streamEnded = true;
53877
55022
  this.callEventTracker.onStreamEnd(false);
@@ -53896,6 +55041,8 @@ var require_server_interceptors = __commonJS({
53896
55041
  if ("grpc.max_receive_message_length" in options) {
53897
55042
  this.maxReceiveMessageSize = options["grpc.max_receive_message_length"];
53898
55043
  }
55044
+ this.host = (_a = headers[":authority"]) !== null && _a !== void 0 ? _a : headers.host;
55045
+ this.decoder = new stream_decoder_1.StreamDecoder(this.maxReceiveMessageSize);
53899
55046
  const metadata = metadata_1.Metadata.fromHttp2Headers(headers);
53900
55047
  if (logging.isTracerEnabled(TRACER_NAME)) {
53901
55048
  trace("Request to " + this.handler.path + " received headers " + JSON.stringify(metadata.toJSON()));
@@ -53988,18 +55135,41 @@ var require_server_interceptors = __commonJS({
53988
55135
  return output;
53989
55136
  }
53990
55137
  decompressMessage(message, encoding) {
53991
- switch (encoding) {
53992
- case "deflate":
53993
- return inflate(message.subarray(5));
53994
- case "gzip":
53995
- return unzip(message.subarray(5));
53996
- case "identity":
53997
- return message.subarray(5);
53998
- default:
53999
- return Promise.reject({
54000
- code: constants_1.Status.UNIMPLEMENTED,
54001
- details: `Received message compressed with unsupported encoding "${encoding}"`
55138
+ const messageContents = message.subarray(5);
55139
+ if (encoding === "identity") {
55140
+ return messageContents;
55141
+ } else if (encoding === "deflate" || encoding === "gzip") {
55142
+ let decompresser;
55143
+ if (encoding === "deflate") {
55144
+ decompresser = zlib.createInflate();
55145
+ } else {
55146
+ decompresser = zlib.createGunzip();
55147
+ }
55148
+ return new Promise((resolve, reject) => {
55149
+ let totalLength = 0;
55150
+ const messageParts = [];
55151
+ decompresser.on("data", (chunk) => {
55152
+ messageParts.push(chunk);
55153
+ totalLength += chunk.byteLength;
55154
+ if (this.maxReceiveMessageSize !== -1 && totalLength > this.maxReceiveMessageSize) {
55155
+ decompresser.destroy();
55156
+ reject({
55157
+ code: constants_1.Status.RESOURCE_EXHAUSTED,
55158
+ details: `Received message that decompresses to a size larger than ${this.maxReceiveMessageSize}`
55159
+ });
55160
+ }
54002
55161
  });
55162
+ decompresser.on("end", () => {
55163
+ resolve(Buffer.concat(messageParts));
55164
+ });
55165
+ decompresser.write(messageContents);
55166
+ decompresser.end();
55167
+ });
55168
+ } else {
55169
+ return Promise.reject({
55170
+ code: constants_1.Status.UNIMPLEMENTED,
55171
+ details: `Received message compressed with unsupported encoding "${encoding}"`
55172
+ });
54003
55173
  }
54004
55174
  }
54005
55175
  async decompressAndMaybePush(queueEntry) {
@@ -54008,7 +55178,13 @@ var require_server_interceptors = __commonJS({
54008
55178
  }
54009
55179
  const compressed = queueEntry.compressedMessage.readUInt8(0) === 1;
54010
55180
  const compressedMessageEncoding = compressed ? this.incomingEncoding : "identity";
54011
- const decompressedMessage = await this.decompressMessage(queueEntry.compressedMessage, compressedMessageEncoding);
55181
+ let decompressedMessage;
55182
+ try {
55183
+ decompressedMessage = await this.decompressMessage(queueEntry.compressedMessage, compressedMessageEncoding);
55184
+ } catch (err) {
55185
+ this.sendStatus(err);
55186
+ return;
55187
+ }
54012
55188
  try {
54013
55189
  queueEntry.parsedMessage = this.handler.deserialize(decompressedMessage);
54014
55190
  } catch (err) {
@@ -54038,17 +55214,15 @@ var require_server_interceptors = __commonJS({
54038
55214
  return;
54039
55215
  }
54040
55216
  trace("Request to " + this.handler.path + " received data frame of size " + data.length);
54041
- const rawMessages = this.decoder.write(data);
55217
+ let rawMessages;
55218
+ try {
55219
+ rawMessages = this.decoder.write(data);
55220
+ } catch (e) {
55221
+ this.sendStatus({ code: constants_1.Status.RESOURCE_EXHAUSTED, details: e.message });
55222
+ return;
55223
+ }
54042
55224
  for (const messageBytes of rawMessages) {
54043
55225
  this.stream.pause();
54044
- if (this.maxReceiveMessageSize !== -1 && messageBytes.length - 5 > this.maxReceiveMessageSize) {
54045
- this.sendStatus({
54046
- code: constants_1.Status.RESOURCE_EXHAUSTED,
54047
- details: `Received message larger than max (${messageBytes.length - 5} vs. ${this.maxReceiveMessageSize})`,
54048
- metadata: null
54049
- });
54050
- return;
54051
- }
54052
55226
  const queueEntry = {
54053
55227
  type: "COMPRESSED",
54054
55228
  compressedMessage: messageBytes,
@@ -54132,9 +55306,8 @@ var require_server_interceptors = __commonJS({
54132
55306
  if (this.checkCancelled()) {
54133
55307
  return;
54134
55308
  }
54135
- this.notifyOnCancel();
54136
55309
  trace("Request to method " + ((_a = this.handler) === null || _a === void 0 ? void 0 : _a.path) + " ended with status code: " + constants_1.Status[status.code] + " details: " + status.details);
54137
- if (this.stream.headersSent) {
55310
+ if (this.metadataSent) {
54138
55311
  if (!this.wantTrailers) {
54139
55312
  this.wantTrailers = true;
54140
55313
  this.stream.once("wantTrailers", () => {
@@ -54146,8 +55319,11 @@ var require_server_interceptors = __commonJS({
54146
55319
  }
54147
55320
  const trailersToSend = Object.assign({ [GRPC_STATUS_HEADER]: status.code, [GRPC_MESSAGE_HEADER]: encodeURI(status.details) }, (_a2 = status.metadata) === null || _a2 === void 0 ? void 0 : _a2.toHttp2Headers());
54148
55321
  this.stream.sendTrailers(trailersToSend);
55322
+ this.notifyOnCancel();
54149
55323
  });
54150
55324
  this.stream.end();
55325
+ } else {
55326
+ this.notifyOnCancel();
54151
55327
  }
54152
55328
  } else {
54153
55329
  if (this.callEventTracker && !this.streamEnded) {
@@ -54157,6 +55333,7 @@ var require_server_interceptors = __commonJS({
54157
55333
  }
54158
55334
  const trailersToSend = Object.assign(Object.assign({ [GRPC_STATUS_HEADER]: status.code, [GRPC_MESSAGE_HEADER]: encodeURI(status.details) }, defaultResponseHeaders), (_b = status.metadata) === null || _b === void 0 ? void 0 : _b.toHttp2Headers());
54159
55335
  this.stream.respond(trailersToSend, { endStream: true });
55336
+ this.notifyOnCancel();
54160
55337
  }
54161
55338
  }
54162
55339
  startRead() {
@@ -54189,6 +55366,9 @@ var require_server_interceptors = __commonJS({
54189
55366
  getDeadline() {
54190
55367
  return this.deadline;
54191
55368
  }
55369
+ getHost() {
55370
+ return this.host;
55371
+ }
54192
55372
  };
54193
55373
  exports2.BaseServerInterceptingCall = BaseServerInterceptingCall;
54194
55374
  function getServerInterceptingCall(interceptors, stream, headers, callEventTracker, handler, options) {
@@ -54267,8 +55447,10 @@ var require_server = __commonJS({
54267
55447
  var UNLIMITED_CONNECTION_AGE_MS = ~(1 << 31);
54268
55448
  var KEEPALIVE_MAX_TIME_MS = ~(1 << 31);
54269
55449
  var KEEPALIVE_TIMEOUT_MS = 2e4;
55450
+ var MAX_CONNECTION_IDLE_MS = ~(1 << 31);
54270
55451
  var { HTTP2_HEADER_PATH } = http2.constants;
54271
55452
  var TRACER_NAME = "server";
55453
+ var kMaxAge = Buffer.from("max_age");
54272
55454
  function noop() {
54273
55455
  }
54274
55456
  function deprecate(message) {
@@ -54311,31 +55493,36 @@ var require_server = __commonJS({
54311
55493
  let _start_decorators;
54312
55494
  return _a = class Server {
54313
55495
  constructor(options) {
54314
- var _b, _c, _d, _e, _f;
55496
+ var _b, _c, _d, _e, _f, _g;
54315
55497
  this.boundPorts = (__runInitializers(this, _instanceExtraInitializers), /* @__PURE__ */ new Map());
54316
55498
  this.http2Servers = /* @__PURE__ */ new Map();
55499
+ this.sessionIdleTimeouts = /* @__PURE__ */ new Map();
54317
55500
  this.handlers = /* @__PURE__ */ new Map();
54318
55501
  this.sessions = /* @__PURE__ */ new Map();
54319
55502
  this.started = false;
54320
55503
  this.shutdown = false;
54321
55504
  this.serverAddressString = "null";
54322
55505
  this.channelzEnabled = true;
54323
- this.channelzTrace = new channelz_1.ChannelzTrace();
54324
- this.callTracker = new channelz_1.ChannelzCallTracker();
54325
- this.listenerChildrenTracker = new channelz_1.ChannelzChildrenTracker();
54326
- this.sessionChildrenTracker = new channelz_1.ChannelzChildrenTracker();
54327
55506
  this.options = options !== null && options !== void 0 ? options : {};
54328
55507
  if (this.options["grpc.enable_channelz"] === 0) {
54329
55508
  this.channelzEnabled = false;
55509
+ this.channelzTrace = new channelz_1.ChannelzTraceStub();
55510
+ this.callTracker = new channelz_1.ChannelzCallTrackerStub();
55511
+ this.listenerChildrenTracker = new channelz_1.ChannelzChildrenTrackerStub();
55512
+ this.sessionChildrenTracker = new channelz_1.ChannelzChildrenTrackerStub();
55513
+ } else {
55514
+ this.channelzTrace = new channelz_1.ChannelzTrace();
55515
+ this.callTracker = new channelz_1.ChannelzCallTracker();
55516
+ this.listenerChildrenTracker = new channelz_1.ChannelzChildrenTracker();
55517
+ this.sessionChildrenTracker = new channelz_1.ChannelzChildrenTracker();
54330
55518
  }
54331
- this.channelzRef = (0, channelz_1.registerChannelzServer)(() => this.getChannelzInfo(), this.channelzEnabled);
54332
- if (this.channelzEnabled) {
54333
- this.channelzTrace.addTrace("CT_INFO", "Server created");
54334
- }
55519
+ this.channelzRef = (0, channelz_1.registerChannelzServer)("server", () => this.getChannelzInfo(), this.channelzEnabled);
55520
+ this.channelzTrace.addTrace("CT_INFO", "Server created");
54335
55521
  this.maxConnectionAgeMs = (_b = this.options["grpc.max_connection_age_ms"]) !== null && _b !== void 0 ? _b : UNLIMITED_CONNECTION_AGE_MS;
54336
55522
  this.maxConnectionAgeGraceMs = (_c = this.options["grpc.max_connection_age_grace_ms"]) !== null && _c !== void 0 ? _c : UNLIMITED_CONNECTION_AGE_MS;
54337
55523
  this.keepaliveTimeMs = (_d = this.options["grpc.keepalive_time_ms"]) !== null && _d !== void 0 ? _d : KEEPALIVE_MAX_TIME_MS;
54338
55524
  this.keepaliveTimeoutMs = (_e = this.options["grpc.keepalive_timeout_ms"]) !== null && _e !== void 0 ? _e : KEEPALIVE_TIMEOUT_MS;
55525
+ this.sessionIdleTimeout = (_f = this.options["grpc.max_connection_idle_ms"]) !== null && _f !== void 0 ? _f : MAX_CONNECTION_IDLE_MS;
54339
55526
  this.commonServerOptions = {
54340
55527
  maxSendHeaderBlockLength: Number.MAX_SAFE_INTEGER
54341
55528
  };
@@ -54349,7 +55536,7 @@ var require_server = __commonJS({
54349
55536
  maxConcurrentStreams: this.options["grpc.max_concurrent_streams"]
54350
55537
  };
54351
55538
  }
54352
- this.interceptors = (_f = this.options.interceptors) !== null && _f !== void 0 ? _f : [];
55539
+ this.interceptors = (_g = this.options.interceptors) !== null && _g !== void 0 ? _g : [];
54353
55540
  this.trace("Server constructed");
54354
55541
  }
54355
55542
  getChannelzInfo() {
@@ -54360,52 +55547,53 @@ var require_server = __commonJS({
54360
55547
  sessionChildren: this.sessionChildrenTracker.getChildLists()
54361
55548
  };
54362
55549
  }
54363
- getChannelzSessionInfoGetter(session) {
54364
- return () => {
54365
- var _b, _c, _d;
54366
- const sessionInfo = this.sessions.get(session);
54367
- const sessionSocket = session.socket;
54368
- const remoteAddress = sessionSocket.remoteAddress ? (0, subchannel_address_1.stringToSubchannelAddress)(sessionSocket.remoteAddress, sessionSocket.remotePort) : null;
54369
- const localAddress = sessionSocket.localAddress ? (0, subchannel_address_1.stringToSubchannelAddress)(sessionSocket.localAddress, sessionSocket.localPort) : null;
54370
- let tlsInfo;
54371
- if (session.encrypted) {
54372
- const tlsSocket = sessionSocket;
54373
- const cipherInfo = tlsSocket.getCipher();
54374
- const certificate = tlsSocket.getCertificate();
54375
- const peerCertificate = tlsSocket.getPeerCertificate();
54376
- tlsInfo = {
54377
- cipherSuiteStandardName: (_b = cipherInfo.standardName) !== null && _b !== void 0 ? _b : null,
54378
- cipherSuiteOtherName: cipherInfo.standardName ? null : cipherInfo.name,
54379
- localCertificate: certificate && "raw" in certificate ? certificate.raw : null,
54380
- remoteCertificate: peerCertificate && "raw" in peerCertificate ? peerCertificate.raw : null
54381
- };
54382
- } else {
54383
- tlsInfo = null;
54384
- }
54385
- const socketInfo = {
54386
- remoteAddress,
54387
- localAddress,
54388
- security: tlsInfo,
54389
- remoteName: null,
54390
- streamsStarted: sessionInfo.streamTracker.callsStarted,
54391
- streamsSucceeded: sessionInfo.streamTracker.callsSucceeded,
54392
- streamsFailed: sessionInfo.streamTracker.callsFailed,
54393
- messagesSent: sessionInfo.messagesSent,
54394
- messagesReceived: sessionInfo.messagesReceived,
54395
- keepAlivesSent: 0,
54396
- lastLocalStreamCreatedTimestamp: null,
54397
- lastRemoteStreamCreatedTimestamp: sessionInfo.streamTracker.lastCallStartedTimestamp,
54398
- lastMessageSentTimestamp: sessionInfo.lastMessageSentTimestamp,
54399
- lastMessageReceivedTimestamp: sessionInfo.lastMessageReceivedTimestamp,
54400
- localFlowControlWindow: (_c = session.state.localWindowSize) !== null && _c !== void 0 ? _c : null,
54401
- remoteFlowControlWindow: (_d = session.state.remoteWindowSize) !== null && _d !== void 0 ? _d : null
55550
+ getChannelzSessionInfo(session) {
55551
+ var _b, _c, _d;
55552
+ const sessionInfo = this.sessions.get(session);
55553
+ const sessionSocket = session.socket;
55554
+ const remoteAddress = sessionSocket.remoteAddress ? (0, subchannel_address_1.stringToSubchannelAddress)(sessionSocket.remoteAddress, sessionSocket.remotePort) : null;
55555
+ const localAddress = sessionSocket.localAddress ? (0, subchannel_address_1.stringToSubchannelAddress)(sessionSocket.localAddress, sessionSocket.localPort) : null;
55556
+ let tlsInfo;
55557
+ if (session.encrypted) {
55558
+ const tlsSocket = sessionSocket;
55559
+ const cipherInfo = tlsSocket.getCipher();
55560
+ const certificate = tlsSocket.getCertificate();
55561
+ const peerCertificate = tlsSocket.getPeerCertificate();
55562
+ tlsInfo = {
55563
+ cipherSuiteStandardName: (_b = cipherInfo.standardName) !== null && _b !== void 0 ? _b : null,
55564
+ cipherSuiteOtherName: cipherInfo.standardName ? null : cipherInfo.name,
55565
+ localCertificate: certificate && "raw" in certificate ? certificate.raw : null,
55566
+ remoteCertificate: peerCertificate && "raw" in peerCertificate ? peerCertificate.raw : null
54402
55567
  };
54403
- return socketInfo;
55568
+ } else {
55569
+ tlsInfo = null;
55570
+ }
55571
+ const socketInfo = {
55572
+ remoteAddress,
55573
+ localAddress,
55574
+ security: tlsInfo,
55575
+ remoteName: null,
55576
+ streamsStarted: sessionInfo.streamTracker.callsStarted,
55577
+ streamsSucceeded: sessionInfo.streamTracker.callsSucceeded,
55578
+ streamsFailed: sessionInfo.streamTracker.callsFailed,
55579
+ messagesSent: sessionInfo.messagesSent,
55580
+ messagesReceived: sessionInfo.messagesReceived,
55581
+ keepAlivesSent: sessionInfo.keepAlivesSent,
55582
+ lastLocalStreamCreatedTimestamp: null,
55583
+ lastRemoteStreamCreatedTimestamp: sessionInfo.streamTracker.lastCallStartedTimestamp,
55584
+ lastMessageSentTimestamp: sessionInfo.lastMessageSentTimestamp,
55585
+ lastMessageReceivedTimestamp: sessionInfo.lastMessageReceivedTimestamp,
55586
+ localFlowControlWindow: (_c = session.state.localWindowSize) !== null && _c !== void 0 ? _c : null,
55587
+ remoteFlowControlWindow: (_d = session.state.remoteWindowSize) !== null && _d !== void 0 ? _d : null
54404
55588
  };
55589
+ return socketInfo;
54405
55590
  }
54406
55591
  trace(text) {
54407
55592
  logging.trace(constants_1.LogVerbosity.DEBUG, TRACER_NAME, "(" + this.channelzRef.id + ") " + text);
54408
55593
  }
55594
+ keepaliveTrace(text) {
55595
+ logging.trace(constants_1.LogVerbosity.DEBUG, "keepalive", "(" + this.channelzRef.id + ") " + text);
55596
+ }
54409
55597
  addProtoService() {
54410
55598
  throw new Error("Not implemented. Use addService() instead");
54411
55599
  }
@@ -54487,19 +55675,35 @@ var require_server = __commonJS({
54487
55675
  createHttp2Server(credentials) {
54488
55676
  let http2Server;
54489
55677
  if (credentials._isSecure()) {
54490
- const secureServerOptions = Object.assign(this.commonServerOptions, credentials._getSettings());
54491
- secureServerOptions.enableTrace = this.options["grpc-node.tls_enable_trace"] === 1;
55678
+ const credentialsSettings = credentials._getSettings();
55679
+ const secureServerOptions = Object.assign(Object.assign(Object.assign({}, this.commonServerOptions), credentialsSettings), { enableTrace: this.options["grpc-node.tls_enable_trace"] === 1 });
55680
+ let areCredentialsValid = credentialsSettings !== null;
54492
55681
  http2Server = http2.createSecureServer(secureServerOptions);
55682
+ http2Server.on("connection", (socket) => {
55683
+ if (!areCredentialsValid) {
55684
+ socket.destroy();
55685
+ }
55686
+ });
54493
55687
  http2Server.on("secureConnection", (socket) => {
54494
55688
  socket.on("error", (e) => {
54495
55689
  this.trace("An incoming TLS connection closed with error: " + e.message);
54496
55690
  });
54497
55691
  });
55692
+ const credsWatcher = (options) => {
55693
+ if (options) {
55694
+ http2Server.setSecureContext(options);
55695
+ }
55696
+ areCredentialsValid = options !== null;
55697
+ };
55698
+ credentials._addWatcher(credsWatcher);
55699
+ http2Server.on("close", () => {
55700
+ credentials._removeWatcher(credsWatcher);
55701
+ });
54498
55702
  } else {
54499
55703
  http2Server = http2.createServer(this.commonServerOptions);
54500
55704
  }
54501
55705
  http2Server.setTimeout(0, noop);
54502
- this._setupHandlers(http2Server);
55706
+ this._setupHandlers(http2Server, credentials._getInterceptors());
54503
55707
  return http2Server;
54504
55708
  }
54505
55709
  bindOneAddress(address, boundPortObject) {
@@ -54528,9 +55732,7 @@ var require_server = __commonJS({
54528
55732
  };
54529
55733
  }
54530
55734
  const channelzRef = this.registerListenerToChannelz(boundSubchannelAddress);
54531
- if (this.channelzEnabled) {
54532
- this.listenerChildrenTracker.refChild(channelzRef);
54533
- }
55735
+ this.listenerChildrenTracker.refChild(channelzRef);
54534
55736
  this.http2Servers.set(http2Server, {
54535
55737
  channelzRef,
54536
55738
  sessions: /* @__PURE__ */ new Set()
@@ -54577,12 +55779,7 @@ var require_server = __commonJS({
54577
55779
  }
54578
55780
  }
54579
55781
  async bindAddressList(addressList, boundPortObject) {
54580
- let bindResult;
54581
- try {
54582
- bindResult = await this.bindManyPorts(addressList, boundPortObject);
54583
- } catch (error) {
54584
- throw error;
54585
- }
55782
+ const bindResult = await this.bindManyPorts(addressList, boundPortObject);
54586
55783
  if (bindResult.count > 0) {
54587
55784
  if (bindResult.count < addressList.length) {
54588
55785
  logging.log(constants_1.LogVerbosity.INFO, `WARNING Only ${bindResult.count} addresses added out of total ${addressList.length} resolved`);
@@ -54709,11 +55906,70 @@ var require_server = __commonJS({
54709
55906
  });
54710
55907
  }
54711
55908
  }
55909
+ registerInjectorToChannelz() {
55910
+ return (0, channelz_1.registerChannelzSocket)("injector", () => {
55911
+ return {
55912
+ localAddress: null,
55913
+ remoteAddress: null,
55914
+ security: null,
55915
+ remoteName: null,
55916
+ streamsStarted: 0,
55917
+ streamsSucceeded: 0,
55918
+ streamsFailed: 0,
55919
+ messagesSent: 0,
55920
+ messagesReceived: 0,
55921
+ keepAlivesSent: 0,
55922
+ lastLocalStreamCreatedTimestamp: null,
55923
+ lastRemoteStreamCreatedTimestamp: null,
55924
+ lastMessageSentTimestamp: null,
55925
+ lastMessageReceivedTimestamp: null,
55926
+ localFlowControlWindow: null,
55927
+ remoteFlowControlWindow: null
55928
+ };
55929
+ }, this.channelzEnabled);
55930
+ }
55931
+ createConnectionInjector(credentials) {
55932
+ if (credentials === null || !(credentials instanceof server_credentials_1.ServerCredentials)) {
55933
+ throw new TypeError("creds must be a ServerCredentials object");
55934
+ }
55935
+ const server = this.createHttp2Server(credentials);
55936
+ const channelzRef = this.registerInjectorToChannelz();
55937
+ if (this.channelzEnabled) {
55938
+ this.listenerChildrenTracker.refChild(channelzRef);
55939
+ }
55940
+ const sessionsSet = /* @__PURE__ */ new Set();
55941
+ this.http2Servers.set(server, {
55942
+ channelzRef,
55943
+ sessions: sessionsSet
55944
+ });
55945
+ return {
55946
+ injectConnection: (connection) => {
55947
+ server.emit("connection", connection);
55948
+ },
55949
+ drain: (graceTimeMs) => {
55950
+ var _b, _c;
55951
+ for (const session of sessionsSet) {
55952
+ this.closeSession(session);
55953
+ }
55954
+ (_c = (_b = setTimeout(() => {
55955
+ for (const session of sessionsSet) {
55956
+ session.destroy(http2.constants.NGHTTP2_CANCEL);
55957
+ }
55958
+ }, graceTimeMs)).unref) === null || _c === void 0 ? void 0 : _c.call(_b);
55959
+ },
55960
+ destroy: () => {
55961
+ this.closeServer(server);
55962
+ for (const session of sessionsSet) {
55963
+ this.closeSession(session);
55964
+ }
55965
+ }
55966
+ };
55967
+ }
54712
55968
  closeServer(server, callback) {
54713
55969
  this.trace("Closing server with address " + JSON.stringify(server.address()));
54714
55970
  const serverInfo = this.http2Servers.get(server);
54715
55971
  server.close(() => {
54716
- if (this.channelzEnabled && serverInfo) {
55972
+ if (serverInfo) {
54717
55973
  this.listenerChildrenTracker.unrefChild(serverInfo.channelzRef);
54718
55974
  (0, channelz_1.unregisterChannelzRef)(serverInfo.channelzRef);
54719
55975
  }
@@ -54726,15 +55982,14 @@ var require_server = __commonJS({
54726
55982
  this.trace("Closing session initiated by " + ((_b = session.socket) === null || _b === void 0 ? void 0 : _b.remoteAddress));
54727
55983
  const sessionInfo = this.sessions.get(session);
54728
55984
  const closeCallback = () => {
54729
- if (this.channelzEnabled && sessionInfo) {
55985
+ if (sessionInfo) {
54730
55986
  this.sessionChildrenTracker.unrefChild(sessionInfo.ref);
54731
55987
  (0, channelz_1.unregisterChannelzRef)(sessionInfo.ref);
54732
55988
  }
54733
- this.sessions.delete(session);
54734
55989
  callback === null || callback === void 0 ? void 0 : callback();
54735
55990
  };
54736
55991
  if (session.closed) {
54737
- process.nextTick(closeCallback);
55992
+ queueMicrotask(closeCallback);
54738
55993
  } else {
54739
55994
  session.close(closeCallback);
54740
55995
  }
@@ -54803,14 +56058,13 @@ var require_server = __commonJS({
54803
56058
  const allSessions = /* @__PURE__ */ new Set();
54804
56059
  for (const http2Server of boundPortObject.listeningServers) {
54805
56060
  const serverEntry = this.http2Servers.get(http2Server);
54806
- if (!serverEntry) {
54807
- continue;
54808
- }
54809
- for (const session of serverEntry.sessions) {
54810
- allSessions.add(session);
54811
- this.closeSession(session, () => {
54812
- allSessions.delete(session);
54813
- });
56061
+ if (serverEntry) {
56062
+ for (const session of serverEntry.sessions) {
56063
+ allSessions.add(session);
56064
+ this.closeSession(session, () => {
56065
+ allSessions.delete(session);
56066
+ });
56067
+ }
54814
56068
  }
54815
56069
  }
54816
56070
  (_c = (_b = setTimeout(() => {
@@ -54832,9 +56086,7 @@ var require_server = __commonJS({
54832
56086
  session.destroy(http2.constants.NGHTTP2_CANCEL);
54833
56087
  });
54834
56088
  this.sessions.clear();
54835
- if (this.channelzEnabled) {
54836
- (0, channelz_1.unregisterChannelzRef)(this.channelzRef);
54837
- }
56089
+ (0, channelz_1.unregisterChannelzRef)(this.channelzRef);
54838
56090
  this.shutdown = true;
54839
56091
  }
54840
56092
  register(name2, handler, serialize, deserialize, type) {
@@ -54868,9 +56120,7 @@ var require_server = __commonJS({
54868
56120
  tryShutdown(callback) {
54869
56121
  var _b;
54870
56122
  const wrappedCallback = (error) => {
54871
- if (this.channelzEnabled) {
54872
- (0, channelz_1.unregisterChannelzRef)(this.channelzRef);
54873
- }
56123
+ (0, channelz_1.unregisterChannelzRef)(this.channelzRef);
54874
56124
  callback(error);
54875
56125
  };
54876
56126
  let pendingChecks = 0;
@@ -54881,23 +56131,23 @@ var require_server = __commonJS({
54881
56131
  }
54882
56132
  }
54883
56133
  this.shutdown = true;
54884
- for (const server of this.http2Servers.keys()) {
56134
+ for (const [serverKey, server] of this.http2Servers.entries()) {
54885
56135
  pendingChecks++;
54886
- const serverString = this.http2Servers.get(server).channelzRef.name;
56136
+ const serverString = server.channelzRef.name;
54887
56137
  this.trace("Waiting for server " + serverString + " to close");
54888
- this.closeServer(server, () => {
56138
+ this.closeServer(serverKey, () => {
54889
56139
  this.trace("Server " + serverString + " finished closing");
54890
56140
  maybeCallback();
54891
56141
  });
54892
- }
54893
- for (const session of this.sessions.keys()) {
54894
- pendingChecks++;
54895
- const sessionString = (_b = session.socket) === null || _b === void 0 ? void 0 : _b.remoteAddress;
54896
- this.trace("Waiting for session " + sessionString + " to close");
54897
- this.closeSession(session, () => {
54898
- this.trace("Session " + sessionString + " finished closing");
54899
- maybeCallback();
54900
- });
56142
+ for (const session of server.sessions.keys()) {
56143
+ pendingChecks++;
56144
+ const sessionString = (_b = session.socket) === null || _b === void 0 ? void 0 : _b.remoteAddress;
56145
+ this.trace("Waiting for session " + sessionString + " to close");
56146
+ this.closeSession(session, () => {
56147
+ this.trace("Session " + sessionString + " finished closing");
56148
+ maybeCallback();
56149
+ });
56150
+ }
54901
56151
  }
54902
56152
  if (pendingChecks === 0) {
54903
56153
  wrappedCallback();
@@ -54937,12 +56187,11 @@ var require_server = __commonJS({
54937
56187
  var _b, _c;
54938
56188
  const trailersToSend = Object.assign({ "grpc-status": (_b = err.code) !== null && _b !== void 0 ? _b : constants_1.Status.INTERNAL, "grpc-message": err.details, [http2.constants.HTTP2_HEADER_STATUS]: http2.constants.HTTP_STATUS_OK, [http2.constants.HTTP2_HEADER_CONTENT_TYPE]: "application/grpc+proto" }, (_c = err.metadata) === null || _c === void 0 ? void 0 : _c.toHttp2Headers());
54939
56189
  stream.respond(trailersToSend, { endStream: true });
54940
- if (this.channelzEnabled) {
54941
- this.callTracker.addCallFailed();
54942
- channelzSessionInfo === null || channelzSessionInfo === void 0 ? void 0 : channelzSessionInfo.streamTracker.addCallFailed();
54943
- }
56190
+ this.callTracker.addCallFailed();
56191
+ channelzSessionInfo === null || channelzSessionInfo === void 0 ? void 0 : channelzSessionInfo.streamTracker.addCallFailed();
54944
56192
  }
54945
- _channelzHandler(stream, headers) {
56193
+ _channelzHandler(extraInterceptors, stream, headers) {
56194
+ this.onStreamOpened(stream);
54946
56195
  const channelzSessionInfo = this.sessions.get(stream.session);
54947
56196
  this.callTracker.addCallStarted();
54948
56197
  channelzSessionInfo === null || channelzSessionInfo === void 0 ? void 0 : channelzSessionInfo.streamTracker.addCallStarted();
@@ -54957,7 +56206,7 @@ var require_server = __commonJS({
54957
56206
  this._respondWithError(getUnimplementedStatusResponse(path), stream, channelzSessionInfo);
54958
56207
  return;
54959
56208
  }
54960
- let callEventTracker = {
56209
+ const callEventTracker = {
54961
56210
  addMessageSent: () => {
54962
56211
  if (channelzSessionInfo) {
54963
56212
  channelzSessionInfo.messagesSent += 1;
@@ -54987,7 +56236,7 @@ var require_server = __commonJS({
54987
56236
  }
54988
56237
  }
54989
56238
  };
54990
- const call = (0, server_interceptors_1.getServerInterceptingCall)(this.interceptors, stream, headers, callEventTracker, handler, this.options);
56239
+ const call = (0, server_interceptors_1.getServerInterceptingCall)([...extraInterceptors, ...this.interceptors], stream, headers, callEventTracker, handler, this.options);
54991
56240
  if (!this._runHandlerForCall(call, handler)) {
54992
56241
  this.callTracker.addCallFailed();
54993
56242
  channelzSessionInfo === null || channelzSessionInfo === void 0 ? void 0 : channelzSessionInfo.streamTracker.addCallFailed();
@@ -54997,7 +56246,8 @@ var require_server = __commonJS({
54997
56246
  });
54998
56247
  }
54999
56248
  }
55000
- _streamHandler(stream, headers) {
56249
+ _streamHandler(extraInterceptors, stream, headers) {
56250
+ this.onStreamOpened(stream);
55001
56251
  if (this._verifyContentType(stream, headers) !== true) {
55002
56252
  return;
55003
56253
  }
@@ -55007,7 +56257,7 @@ var require_server = __commonJS({
55007
56257
  this._respondWithError(getUnimplementedStatusResponse(path), stream, null);
55008
56258
  return;
55009
56259
  }
55010
- const call = (0, server_interceptors_1.getServerInterceptingCall)(this.interceptors, stream, headers, null, handler, this.options);
56260
+ const call = (0, server_interceptors_1.getServerInterceptingCall)([...extraInterceptors, ...this.interceptors], stream, headers, null, handler, this.options);
55011
56261
  if (!this._runHandlerForCall(call, handler)) {
55012
56262
  call.sendStatus({
55013
56263
  code: constants_1.Status.INTERNAL,
@@ -55030,7 +56280,7 @@ var require_server = __commonJS({
55030
56280
  }
55031
56281
  return true;
55032
56282
  }
55033
- _setupHandlers(http2Server) {
56283
+ _setupHandlers(http2Server, extraInterceptors) {
55034
56284
  if (http2Server === null) {
55035
56285
  return;
55036
56286
  }
@@ -55045,90 +56295,310 @@ var require_server = __commonJS({
55045
56295
  }
55046
56296
  this.serverAddressString = serverAddressString;
55047
56297
  const handler = this.channelzEnabled ? this._channelzHandler : this._streamHandler;
55048
- http2Server.on("stream", handler.bind(this));
55049
- http2Server.on("session", (session) => {
55050
- var _b, _c, _d, _e, _f, _g;
55051
- const channelzRef = (0, channelz_1.registerChannelzSocket)((_b = session.socket.remoteAddress) !== null && _b !== void 0 ? _b : "unknown", this.getChannelzSessionInfoGetter(session), this.channelzEnabled);
56298
+ const sessionHandler = this.channelzEnabled ? this._channelzSessionHandler(http2Server) : this._sessionHandler(http2Server);
56299
+ http2Server.on("stream", handler.bind(this, extraInterceptors));
56300
+ http2Server.on("session", sessionHandler);
56301
+ }
56302
+ _sessionHandler(http2Server) {
56303
+ return (session) => {
56304
+ var _b, _c;
56305
+ (_b = this.http2Servers.get(http2Server)) === null || _b === void 0 ? void 0 : _b.sessions.add(session);
56306
+ let connectionAgeTimer = null;
56307
+ let connectionAgeGraceTimer = null;
56308
+ let keepaliveTimer = null;
56309
+ let sessionClosedByServer = false;
56310
+ const idleTimeoutObj = this.enableIdleTimeout(session);
56311
+ if (this.maxConnectionAgeMs !== UNLIMITED_CONNECTION_AGE_MS) {
56312
+ const jitterMagnitude = this.maxConnectionAgeMs / 10;
56313
+ const jitter = Math.random() * jitterMagnitude * 2 - jitterMagnitude;
56314
+ connectionAgeTimer = setTimeout(() => {
56315
+ var _b2, _c2;
56316
+ sessionClosedByServer = true;
56317
+ this.trace("Connection dropped by max connection age: " + ((_b2 = session.socket) === null || _b2 === void 0 ? void 0 : _b2.remoteAddress));
56318
+ try {
56319
+ session.goaway(http2.constants.NGHTTP2_NO_ERROR, ~(1 << 31), kMaxAge);
56320
+ } catch (e) {
56321
+ session.destroy();
56322
+ return;
56323
+ }
56324
+ session.close();
56325
+ if (this.maxConnectionAgeGraceMs !== UNLIMITED_CONNECTION_AGE_MS) {
56326
+ connectionAgeGraceTimer = setTimeout(() => {
56327
+ session.destroy();
56328
+ }, this.maxConnectionAgeGraceMs);
56329
+ (_c2 = connectionAgeGraceTimer.unref) === null || _c2 === void 0 ? void 0 : _c2.call(connectionAgeGraceTimer);
56330
+ }
56331
+ }, this.maxConnectionAgeMs + jitter);
56332
+ (_c = connectionAgeTimer.unref) === null || _c === void 0 ? void 0 : _c.call(connectionAgeTimer);
56333
+ }
56334
+ const clearKeepaliveTimeout = () => {
56335
+ if (keepaliveTimer) {
56336
+ clearTimeout(keepaliveTimer);
56337
+ keepaliveTimer = null;
56338
+ }
56339
+ };
56340
+ const canSendPing = () => {
56341
+ return !session.destroyed && this.keepaliveTimeMs < KEEPALIVE_MAX_TIME_MS && this.keepaliveTimeMs > 0;
56342
+ };
56343
+ let sendPing;
56344
+ const maybeStartKeepalivePingTimer = () => {
56345
+ var _b2;
56346
+ if (!canSendPing()) {
56347
+ return;
56348
+ }
56349
+ this.keepaliveTrace("Starting keepalive timer for " + this.keepaliveTimeMs + "ms");
56350
+ keepaliveTimer = setTimeout(() => {
56351
+ clearKeepaliveTimeout();
56352
+ sendPing();
56353
+ }, this.keepaliveTimeMs);
56354
+ (_b2 = keepaliveTimer.unref) === null || _b2 === void 0 ? void 0 : _b2.call(keepaliveTimer);
56355
+ };
56356
+ sendPing = () => {
56357
+ var _b2;
56358
+ if (!canSendPing()) {
56359
+ return;
56360
+ }
56361
+ this.keepaliveTrace("Sending ping with timeout " + this.keepaliveTimeoutMs + "ms");
56362
+ let pingSendError = "";
56363
+ try {
56364
+ const pingSentSuccessfully = session.ping((err, duration, payload) => {
56365
+ clearKeepaliveTimeout();
56366
+ if (err) {
56367
+ this.keepaliveTrace("Ping failed with error: " + err.message);
56368
+ sessionClosedByServer = true;
56369
+ session.close();
56370
+ } else {
56371
+ this.keepaliveTrace("Received ping response");
56372
+ maybeStartKeepalivePingTimer();
56373
+ }
56374
+ });
56375
+ if (!pingSentSuccessfully) {
56376
+ pingSendError = "Ping returned false";
56377
+ }
56378
+ } catch (e) {
56379
+ pingSendError = (e instanceof Error ? e.message : "") || "Unknown error";
56380
+ }
56381
+ if (pingSendError) {
56382
+ this.keepaliveTrace("Ping send failed: " + pingSendError);
56383
+ this.trace("Connection dropped due to ping send error: " + pingSendError);
56384
+ sessionClosedByServer = true;
56385
+ session.close();
56386
+ return;
56387
+ }
56388
+ keepaliveTimer = setTimeout(() => {
56389
+ clearKeepaliveTimeout();
56390
+ this.keepaliveTrace("Ping timeout passed without response");
56391
+ this.trace("Connection dropped by keepalive timeout");
56392
+ sessionClosedByServer = true;
56393
+ session.close();
56394
+ }, this.keepaliveTimeoutMs);
56395
+ (_b2 = keepaliveTimer.unref) === null || _b2 === void 0 ? void 0 : _b2.call(keepaliveTimer);
56396
+ };
56397
+ maybeStartKeepalivePingTimer();
56398
+ session.on("close", () => {
56399
+ var _b2, _c2;
56400
+ if (!sessionClosedByServer) {
56401
+ this.trace(`Connection dropped by client ${(_b2 = session.socket) === null || _b2 === void 0 ? void 0 : _b2.remoteAddress}`);
56402
+ }
56403
+ if (connectionAgeTimer) {
56404
+ clearTimeout(connectionAgeTimer);
56405
+ }
56406
+ if (connectionAgeGraceTimer) {
56407
+ clearTimeout(connectionAgeGraceTimer);
56408
+ }
56409
+ clearKeepaliveTimeout();
56410
+ if (idleTimeoutObj !== null) {
56411
+ clearTimeout(idleTimeoutObj.timeout);
56412
+ this.sessionIdleTimeouts.delete(session);
56413
+ }
56414
+ (_c2 = this.http2Servers.get(http2Server)) === null || _c2 === void 0 ? void 0 : _c2.sessions.delete(session);
56415
+ });
56416
+ };
56417
+ }
56418
+ _channelzSessionHandler(http2Server) {
56419
+ return (session) => {
56420
+ var _b, _c, _d, _e;
56421
+ const channelzRef = (0, channelz_1.registerChannelzSocket)((_c = (_b = session.socket) === null || _b === void 0 ? void 0 : _b.remoteAddress) !== null && _c !== void 0 ? _c : "unknown", this.getChannelzSessionInfo.bind(this, session), this.channelzEnabled);
55052
56422
  const channelzSessionInfo = {
55053
56423
  ref: channelzRef,
55054
56424
  streamTracker: new channelz_1.ChannelzCallTracker(),
55055
56425
  messagesSent: 0,
55056
56426
  messagesReceived: 0,
56427
+ keepAlivesSent: 0,
55057
56428
  lastMessageSentTimestamp: null,
55058
56429
  lastMessageReceivedTimestamp: null
55059
56430
  };
55060
- (_c = this.http2Servers.get(http2Server)) === null || _c === void 0 ? void 0 : _c.sessions.add(session);
56431
+ (_d = this.http2Servers.get(http2Server)) === null || _d === void 0 ? void 0 : _d.sessions.add(session);
55061
56432
  this.sessions.set(session, channelzSessionInfo);
55062
- const clientAddress = session.socket.remoteAddress;
55063
- if (this.channelzEnabled) {
55064
- this.channelzTrace.addTrace("CT_INFO", "Connection established by client " + clientAddress);
55065
- this.sessionChildrenTracker.refChild(channelzRef);
55066
- }
56433
+ const clientAddress = `${session.socket.remoteAddress}:${session.socket.remotePort}`;
56434
+ this.channelzTrace.addTrace("CT_INFO", "Connection established by client " + clientAddress);
56435
+ this.trace("Connection established by client " + clientAddress);
56436
+ this.sessionChildrenTracker.refChild(channelzRef);
55067
56437
  let connectionAgeTimer = null;
55068
56438
  let connectionAgeGraceTimer = null;
56439
+ let keepaliveTimeout = null;
55069
56440
  let sessionClosedByServer = false;
56441
+ const idleTimeoutObj = this.enableIdleTimeout(session);
55070
56442
  if (this.maxConnectionAgeMs !== UNLIMITED_CONNECTION_AGE_MS) {
55071
56443
  const jitterMagnitude = this.maxConnectionAgeMs / 10;
55072
56444
  const jitter = Math.random() * jitterMagnitude * 2 - jitterMagnitude;
55073
- connectionAgeTimer = (_e = (_d = setTimeout(() => {
55074
- var _b2, _c2;
56445
+ connectionAgeTimer = setTimeout(() => {
56446
+ var _b2;
55075
56447
  sessionClosedByServer = true;
55076
- if (this.channelzEnabled) {
55077
- this.channelzTrace.addTrace("CT_INFO", "Connection dropped by max connection age from " + clientAddress);
55078
- }
56448
+ this.channelzTrace.addTrace("CT_INFO", "Connection dropped by max connection age from " + clientAddress);
55079
56449
  try {
55080
- session.goaway(http2.constants.NGHTTP2_NO_ERROR, ~(1 << 31), Buffer.from("max_age"));
56450
+ session.goaway(http2.constants.NGHTTP2_NO_ERROR, ~(1 << 31), kMaxAge);
55081
56451
  } catch (e) {
55082
56452
  session.destroy();
55083
56453
  return;
55084
56454
  }
55085
56455
  session.close();
55086
56456
  if (this.maxConnectionAgeGraceMs !== UNLIMITED_CONNECTION_AGE_MS) {
55087
- connectionAgeGraceTimer = (_c2 = (_b2 = setTimeout(() => {
56457
+ connectionAgeGraceTimer = setTimeout(() => {
55088
56458
  session.destroy();
55089
- }, this.maxConnectionAgeGraceMs)).unref) === null || _c2 === void 0 ? void 0 : _c2.call(_b2);
56459
+ }, this.maxConnectionAgeGraceMs);
56460
+ (_b2 = connectionAgeGraceTimer.unref) === null || _b2 === void 0 ? void 0 : _b2.call(connectionAgeGraceTimer);
55090
56461
  }
55091
- }, this.maxConnectionAgeMs + jitter)).unref) === null || _e === void 0 ? void 0 : _e.call(_d);
56462
+ }, this.maxConnectionAgeMs + jitter);
56463
+ (_e = connectionAgeTimer.unref) === null || _e === void 0 ? void 0 : _e.call(connectionAgeTimer);
55092
56464
  }
55093
- const keeapliveTimeTimer = (_g = (_f = setInterval(() => {
55094
- var _b2, _c2;
55095
- const timeoutTImer = (_c2 = (_b2 = setTimeout(() => {
55096
- sessionClosedByServer = true;
55097
- if (this.channelzEnabled) {
55098
- this.channelzTrace.addTrace("CT_INFO", "Connection dropped by keepalive timeout from " + clientAddress);
55099
- }
55100
- session.close();
55101
- }, this.keepaliveTimeoutMs)).unref) === null || _c2 === void 0 ? void 0 : _c2.call(_b2);
56465
+ const clearKeepaliveTimeout = () => {
56466
+ if (keepaliveTimeout) {
56467
+ clearTimeout(keepaliveTimeout);
56468
+ keepaliveTimeout = null;
56469
+ }
56470
+ };
56471
+ const canSendPing = () => {
56472
+ return !session.destroyed && this.keepaliveTimeMs < KEEPALIVE_MAX_TIME_MS && this.keepaliveTimeMs > 0;
56473
+ };
56474
+ let sendPing;
56475
+ const maybeStartKeepalivePingTimer = () => {
56476
+ var _b2;
56477
+ if (!canSendPing()) {
56478
+ return;
56479
+ }
56480
+ this.keepaliveTrace("Starting keepalive timer for " + this.keepaliveTimeMs + "ms");
56481
+ keepaliveTimeout = setTimeout(() => {
56482
+ clearKeepaliveTimeout();
56483
+ sendPing();
56484
+ }, this.keepaliveTimeMs);
56485
+ (_b2 = keepaliveTimeout.unref) === null || _b2 === void 0 ? void 0 : _b2.call(keepaliveTimeout);
56486
+ };
56487
+ sendPing = () => {
56488
+ var _b2;
56489
+ if (!canSendPing()) {
56490
+ return;
56491
+ }
56492
+ this.keepaliveTrace("Sending ping with timeout " + this.keepaliveTimeoutMs + "ms");
56493
+ let pingSendError = "";
55102
56494
  try {
55103
- session.ping((err, duration, payload) => {
55104
- clearTimeout(timeoutTImer);
56495
+ const pingSentSuccessfully = session.ping((err, duration, payload) => {
56496
+ clearKeepaliveTimeout();
56497
+ if (err) {
56498
+ this.keepaliveTrace("Ping failed with error: " + err.message);
56499
+ this.channelzTrace.addTrace("CT_INFO", "Connection dropped due to error of a ping frame " + err.message + " return in " + duration);
56500
+ sessionClosedByServer = true;
56501
+ session.close();
56502
+ } else {
56503
+ this.keepaliveTrace("Received ping response");
56504
+ maybeStartKeepalivePingTimer();
56505
+ }
55105
56506
  });
56507
+ if (!pingSentSuccessfully) {
56508
+ pingSendError = "Ping returned false";
56509
+ }
55106
56510
  } catch (e) {
55107
- session.destroy();
56511
+ pingSendError = (e instanceof Error ? e.message : "") || "Unknown error";
55108
56512
  }
55109
- }, this.keepaliveTimeMs)).unref) === null || _g === void 0 ? void 0 : _g.call(_f);
56513
+ if (pingSendError) {
56514
+ this.keepaliveTrace("Ping send failed: " + pingSendError);
56515
+ this.channelzTrace.addTrace("CT_INFO", "Connection dropped due to ping send error: " + pingSendError);
56516
+ sessionClosedByServer = true;
56517
+ session.close();
56518
+ return;
56519
+ }
56520
+ channelzSessionInfo.keepAlivesSent += 1;
56521
+ keepaliveTimeout = setTimeout(() => {
56522
+ clearKeepaliveTimeout();
56523
+ this.keepaliveTrace("Ping timeout passed without response");
56524
+ this.channelzTrace.addTrace("CT_INFO", "Connection dropped by keepalive timeout from " + clientAddress);
56525
+ sessionClosedByServer = true;
56526
+ session.close();
56527
+ }, this.keepaliveTimeoutMs);
56528
+ (_b2 = keepaliveTimeout.unref) === null || _b2 === void 0 ? void 0 : _b2.call(keepaliveTimeout);
56529
+ };
56530
+ maybeStartKeepalivePingTimer();
55110
56531
  session.on("close", () => {
55111
56532
  var _b2;
55112
- if (this.channelzEnabled) {
55113
- if (!sessionClosedByServer) {
55114
- this.channelzTrace.addTrace("CT_INFO", "Connection dropped by client " + clientAddress);
55115
- }
55116
- this.sessionChildrenTracker.unrefChild(channelzRef);
55117
- (0, channelz_1.unregisterChannelzRef)(channelzRef);
56533
+ if (!sessionClosedByServer) {
56534
+ this.channelzTrace.addTrace("CT_INFO", "Connection dropped by client " + clientAddress);
55118
56535
  }
56536
+ this.sessionChildrenTracker.unrefChild(channelzRef);
56537
+ (0, channelz_1.unregisterChannelzRef)(channelzRef);
55119
56538
  if (connectionAgeTimer) {
55120
56539
  clearTimeout(connectionAgeTimer);
55121
56540
  }
55122
56541
  if (connectionAgeGraceTimer) {
55123
56542
  clearTimeout(connectionAgeGraceTimer);
55124
56543
  }
55125
- if (keeapliveTimeTimer) {
55126
- clearTimeout(keeapliveTimeTimer);
56544
+ clearKeepaliveTimeout();
56545
+ if (idleTimeoutObj !== null) {
56546
+ clearTimeout(idleTimeoutObj.timeout);
56547
+ this.sessionIdleTimeouts.delete(session);
55127
56548
  }
55128
56549
  (_b2 = this.http2Servers.get(http2Server)) === null || _b2 === void 0 ? void 0 : _b2.sessions.delete(session);
55129
56550
  this.sessions.delete(session);
55130
56551
  });
55131
- });
56552
+ };
56553
+ }
56554
+ enableIdleTimeout(session) {
56555
+ var _b, _c;
56556
+ if (this.sessionIdleTimeout >= MAX_CONNECTION_IDLE_MS) {
56557
+ return null;
56558
+ }
56559
+ const idleTimeoutObj = {
56560
+ activeStreams: 0,
56561
+ lastIdle: Date.now(),
56562
+ onClose: this.onStreamClose.bind(this, session),
56563
+ timeout: setTimeout(this.onIdleTimeout, this.sessionIdleTimeout, this, session)
56564
+ };
56565
+ (_c = (_b = idleTimeoutObj.timeout).unref) === null || _c === void 0 ? void 0 : _c.call(_b);
56566
+ this.sessionIdleTimeouts.set(session, idleTimeoutObj);
56567
+ const { socket } = session;
56568
+ this.trace("Enable idle timeout for " + socket.remoteAddress + ":" + socket.remotePort);
56569
+ return idleTimeoutObj;
56570
+ }
56571
+ onIdleTimeout(ctx, session) {
56572
+ const { socket } = session;
56573
+ const sessionInfo = ctx.sessionIdleTimeouts.get(session);
56574
+ if (sessionInfo !== void 0 && sessionInfo.activeStreams === 0) {
56575
+ if (Date.now() - sessionInfo.lastIdle >= ctx.sessionIdleTimeout) {
56576
+ ctx.trace("Session idle timeout triggered for " + (socket === null || socket === void 0 ? void 0 : socket.remoteAddress) + ":" + (socket === null || socket === void 0 ? void 0 : socket.remotePort) + " last idle at " + sessionInfo.lastIdle);
56577
+ ctx.closeSession(session);
56578
+ } else {
56579
+ sessionInfo.timeout.refresh();
56580
+ }
56581
+ }
56582
+ }
56583
+ onStreamOpened(stream) {
56584
+ const session = stream.session;
56585
+ const idleTimeoutObj = this.sessionIdleTimeouts.get(session);
56586
+ if (idleTimeoutObj) {
56587
+ idleTimeoutObj.activeStreams += 1;
56588
+ stream.once("close", idleTimeoutObj.onClose);
56589
+ }
56590
+ }
56591
+ onStreamClose(session) {
56592
+ var _b, _c;
56593
+ const idleTimeoutObj = this.sessionIdleTimeouts.get(session);
56594
+ if (idleTimeoutObj) {
56595
+ idleTimeoutObj.activeStreams -= 1;
56596
+ if (idleTimeoutObj.activeStreams === 0) {
56597
+ idleTimeoutObj.lastIdle = Date.now();
56598
+ idleTimeoutObj.timeout.refresh();
56599
+ this.trace("Session onStreamClose" + ((_b = session.socket) === null || _b === void 0 ? void 0 : _b.remoteAddress) + ":" + ((_c = session.socket) === null || _c === void 0 ? void 0 : _c.remotePort) + " at " + idleTimeoutObj.lastIdle);
56600
+ }
56601
+ }
55132
56602
  }
55133
56603
  }, (() => {
55134
56604
  const _metadata = typeof Symbol === "function" && Symbol.metadata ? /* @__PURE__ */ Object.create(null) : void 0;
@@ -55413,9 +56883,10 @@ var require_load_balancer_pick_first = __commonJS({
55413
56883
  var load_balancer_1 = require_load_balancer();
55414
56884
  var connectivity_state_1 = require_connectivity_state();
55415
56885
  var picker_1 = require_picker();
56886
+ var subchannel_address_1 = require_subchannel_address();
55416
56887
  var logging = require_logging();
55417
56888
  var constants_1 = require_constants8();
55418
- var subchannel_address_1 = require_subchannel_address();
56889
+ var subchannel_address_2 = require_subchannel_address();
55419
56890
  var net_1 = __require("net");
55420
56891
  var TRACER_NAME = "pick_first";
55421
56892
  function trace(text) {
@@ -55478,9 +56949,9 @@ var require_load_balancer_pick_first = __commonJS({
55478
56949
  const result = [];
55479
56950
  const ipv6Addresses = [];
55480
56951
  const ipv4Addresses = [];
55481
- const ipv6First = (0, subchannel_address_1.isTcpSubchannelAddress)(addressList[0]) && (0, net_1.isIPv6)(addressList[0].host);
56952
+ const ipv6First = (0, subchannel_address_2.isTcpSubchannelAddress)(addressList[0]) && (0, net_1.isIPv6)(addressList[0].host);
55482
56953
  for (const address of addressList) {
55483
- if ((0, subchannel_address_1.isTcpSubchannelAddress)(address) && (0, net_1.isIPv6)(address.host)) {
56954
+ if ((0, subchannel_address_2.isTcpSubchannelAddress)(address) && (0, net_1.isIPv6)(address.host)) {
55484
56955
  ipv6Addresses.push(address);
55485
56956
  } else {
55486
56957
  ipv4Addresses.push(address);
@@ -55517,9 +56988,7 @@ var require_load_balancer_pick_first = __commonJS({
55517
56988
  this.onSubchannelStateUpdate(subchannel, previousState, newState, errorMessage);
55518
56989
  };
55519
56990
  this.pickedSubchannelHealthListener = () => this.calculateAndReportNewState();
55520
- this.triedAllSubchannels = false;
55521
56991
  this.stickyTransientFailureMode = false;
55522
- this.requestedResolutionSinceLastUpdate = false;
55523
56992
  this.lastError = null;
55524
56993
  this.latestAddressList = null;
55525
56994
  this.connectionDelayTimeout = setTimeout(() => {
@@ -55530,6 +56999,9 @@ var require_load_balancer_pick_first = __commonJS({
55530
56999
  allChildrenHaveReportedTF() {
55531
57000
  return this.children.every((child) => child.hasReportedTransientFailure);
55532
57001
  }
57002
+ resetChildrenReportedTF() {
57003
+ this.children.every((child) => child.hasReportedTransientFailure = false);
57004
+ }
55533
57005
  calculateAndReportNewState() {
55534
57006
  if (this.currentPick) {
55535
57007
  if (this.reportHealthStatus && !this.currentPick.isHealthy()) {
@@ -55543,23 +57015,23 @@ var require_load_balancer_pick_first = __commonJS({
55543
57015
  this.updateState(connectivity_state_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this));
55544
57016
  } else {
55545
57017
  if (this.stickyTransientFailureMode) {
55546
- this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({ details: `No connection established. Last error: ${this.lastError}` }));
57018
+ this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
57019
+ details: `No connection established. Last error: ${this.lastError}`
57020
+ }));
55547
57021
  } else {
55548
57022
  this.updateState(connectivity_state_1.ConnectivityState.CONNECTING, new picker_1.QueuePicker(this));
55549
57023
  }
55550
57024
  }
55551
57025
  }
55552
57026
  requestReresolution() {
55553
- this.requestedResolutionSinceLastUpdate = true;
55554
57027
  this.channelControlHelper.requestReresolution();
55555
57028
  }
55556
57029
  maybeEnterStickyTransientFailureMode() {
55557
57030
  if (!this.allChildrenHaveReportedTF()) {
55558
57031
  return;
55559
57032
  }
55560
- if (!this.requestedResolutionSinceLastUpdate) {
55561
- this.requestReresolution();
55562
- }
57033
+ this.requestReresolution();
57034
+ this.resetChildrenReportedTF();
55563
57035
  if (this.stickyTransientFailureMode) {
55564
57036
  return;
55565
57037
  }
@@ -55571,14 +57043,11 @@ var require_load_balancer_pick_first = __commonJS({
55571
57043
  }
55572
57044
  removeCurrentPick() {
55573
57045
  if (this.currentPick !== null) {
55574
- const currentPick = this.currentPick;
57046
+ this.currentPick.removeConnectivityStateListener(this.subchannelStateListener);
57047
+ this.channelControlHelper.removeChannelzChild(this.currentPick.getChannelzRef());
57048
+ this.currentPick.removeHealthStateWatcher(this.pickedSubchannelHealthListener);
57049
+ this.currentPick.unref();
55575
57050
  this.currentPick = null;
55576
- currentPick.unref();
55577
- currentPick.removeConnectivityStateListener(this.subchannelStateListener);
55578
- this.channelControlHelper.removeChannelzChild(currentPick.getChannelzRef());
55579
- if (this.reportHealthStatus) {
55580
- currentPick.removeHealthStateWatcher(this.pickedSubchannelHealthListener);
55581
- }
55582
57051
  }
55583
57052
  }
55584
57053
  onSubchannelStateUpdate(subchannel, previousState, newState, errorMessage) {
@@ -55587,7 +57056,6 @@ var require_load_balancer_pick_first = __commonJS({
55587
57056
  if (newState !== connectivity_state_1.ConnectivityState.READY) {
55588
57057
  this.removeCurrentPick();
55589
57058
  this.calculateAndReportNewState();
55590
- this.requestReresolution();
55591
57059
  }
55592
57060
  return;
55593
57061
  }
@@ -55613,9 +57081,6 @@ var require_load_balancer_pick_first = __commonJS({
55613
57081
  }
55614
57082
  startNextSubchannelConnecting(startIndex) {
55615
57083
  clearTimeout(this.connectionDelayTimeout);
55616
- if (this.triedAllSubchannels) {
55617
- return;
55618
- }
55619
57084
  for (const [index, child] of this.children.entries()) {
55620
57085
  if (index >= startIndex) {
55621
57086
  const subchannelState = child.subchannel.getConnectivityState();
@@ -55625,7 +57090,6 @@ var require_load_balancer_pick_first = __commonJS({
55625
57090
  }
55626
57091
  }
55627
57092
  }
55628
- this.triedAllSubchannels = true;
55629
57093
  this.maybeEnterStickyTransientFailureMode();
55630
57094
  }
55631
57095
  /**
@@ -55643,24 +57107,28 @@ var require_load_balancer_pick_first = __commonJS({
55643
57107
  (_a2 = this.children[subchannelIndex]) === null || _a2 === void 0 ? void 0 : _a2.subchannel.startConnecting();
55644
57108
  });
55645
57109
  }
55646
- this.connectionDelayTimeout = (_b = (_a = setTimeout(() => {
57110
+ this.connectionDelayTimeout = setTimeout(() => {
55647
57111
  this.startNextSubchannelConnecting(subchannelIndex + 1);
55648
- }, CONNECTION_DELAY_INTERVAL_MS)).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
57112
+ }, CONNECTION_DELAY_INTERVAL_MS);
57113
+ (_b = (_a = this.connectionDelayTimeout).unref) === null || _b === void 0 ? void 0 : _b.call(_a);
55649
57114
  }
57115
+ /**
57116
+ * Declare that the specified subchannel should be used to make requests.
57117
+ * This functions the same independent of whether subchannel is a member of
57118
+ * this.children and whether it is equal to this.currentPick.
57119
+ * Prerequisite: subchannel.getConnectivityState() === READY.
57120
+ * @param subchannel
57121
+ */
55650
57122
  pickSubchannel(subchannel) {
55651
- if (this.currentPick && subchannel.realSubchannelEquals(this.currentPick)) {
55652
- return;
55653
- }
55654
57123
  trace("Pick subchannel with address " + subchannel.getAddress());
55655
57124
  this.stickyTransientFailureMode = false;
55656
- this.removeCurrentPick();
55657
- this.currentPick = subchannel;
55658
57125
  subchannel.ref();
55659
- if (this.reportHealthStatus) {
55660
- subchannel.addHealthStateWatcher(this.pickedSubchannelHealthListener);
55661
- }
55662
57126
  this.channelControlHelper.addChannelzChild(subchannel.getChannelzRef());
57127
+ this.removeCurrentPick();
55663
57128
  this.resetSubchannelList();
57129
+ subchannel.addConnectivityStateListener(this.subchannelStateListener);
57130
+ subchannel.addHealthStateWatcher(this.pickedSubchannelHealthListener);
57131
+ this.currentPick = subchannel;
55664
57132
  clearTimeout(this.connectionDelayTimeout);
55665
57133
  this.calculateAndReportNewState();
55666
57134
  }
@@ -55671,22 +57139,25 @@ var require_load_balancer_pick_first = __commonJS({
55671
57139
  }
55672
57140
  resetSubchannelList() {
55673
57141
  for (const child of this.children) {
55674
- if (!(this.currentPick && child.subchannel.realSubchannelEquals(this.currentPick))) {
55675
- child.subchannel.removeConnectivityStateListener(this.subchannelStateListener);
55676
- }
57142
+ child.subchannel.removeConnectivityStateListener(this.subchannelStateListener);
55677
57143
  child.subchannel.unref();
55678
57144
  this.channelControlHelper.removeChannelzChild(child.subchannel.getChannelzRef());
55679
57145
  }
55680
57146
  this.currentSubchannelIndex = 0;
55681
57147
  this.children = [];
55682
- this.triedAllSubchannels = false;
55683
- this.requestedResolutionSinceLastUpdate = false;
55684
57148
  }
55685
57149
  connectToAddressList(addressList) {
57150
+ trace("connectToAddressList([" + addressList.map((address) => (0, subchannel_address_1.subchannelAddressToString)(address)) + "])");
55686
57151
  const newChildrenList = addressList.map((address) => ({
55687
57152
  subchannel: this.channelControlHelper.createSubchannel(address, {}),
55688
57153
  hasReportedTransientFailure: false
55689
57154
  }));
57155
+ for (const { subchannel } of newChildrenList) {
57156
+ if (subchannel.getConnectivityState() === connectivity_state_1.ConnectivityState.READY) {
57157
+ this.pickSubchannel(subchannel);
57158
+ return;
57159
+ }
57160
+ }
55690
57161
  for (const { subchannel } of newChildrenList) {
55691
57162
  subchannel.ref();
55692
57163
  this.channelControlHelper.addChannelzChild(subchannel.getChannelzRef());
@@ -55695,10 +57166,6 @@ var require_load_balancer_pick_first = __commonJS({
55695
57166
  this.children = newChildrenList;
55696
57167
  for (const { subchannel } of this.children) {
55697
57168
  subchannel.addConnectivityStateListener(this.subchannelStateListener);
55698
- if (subchannel.getConnectivityState() === connectivity_state_1.ConnectivityState.READY) {
55699
- this.pickSubchannel(subchannel);
55700
- return;
55701
- }
55702
57169
  }
55703
57170
  for (const child of this.children) {
55704
57171
  if (child.subchannel.getConnectivityState() === connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE) {
@@ -55716,6 +57183,7 @@ var require_load_balancer_pick_first = __commonJS({
55716
57183
  endpointList = shuffled(endpointList);
55717
57184
  }
55718
57185
  const rawAddressList = [].concat(...endpointList.map((endpoint) => endpoint.addresses));
57186
+ trace("updateAddressList([" + rawAddressList.map((address) => (0, subchannel_address_1.subchannelAddressToString)(address)) + "])");
55719
57187
  if (rawAddressList.length === 0) {
55720
57188
  throw new Error("No addresses in endpoint list passed to pick_first");
55721
57189
  }
@@ -55799,7 +57267,7 @@ var require_experimental = __commonJS({
55799
57267
  "node_modules/@grpc/grpc-js/build/src/experimental.js"(exports2) {
55800
57268
  "use strict";
55801
57269
  Object.defineProperty(exports2, "__esModule", { value: true });
55802
- exports2.BaseSubchannelWrapper = exports2.registerAdminService = exports2.FilterStackFactory = exports2.BaseFilter = exports2.PickResultType = exports2.QueuePicker = exports2.UnavailablePicker = exports2.ChildLoadBalancerHandler = exports2.EndpointMap = exports2.endpointHasAddress = exports2.endpointToString = exports2.subchannelAddressToString = exports2.LeafLoadBalancer = exports2.isLoadBalancerNameRegistered = exports2.parseLoadBalancingConfig = exports2.selectLbConfigFromList = exports2.registerLoadBalancerType = exports2.createChildChannelControlHelper = exports2.BackoffTimeout = exports2.durationToMs = exports2.uriToString = exports2.createResolver = exports2.registerResolver = exports2.log = exports2.trace = void 0;
57270
+ exports2.createServerCredentialsWithInterceptors = exports2.BaseSubchannelWrapper = exports2.registerAdminService = exports2.FilterStackFactory = exports2.BaseFilter = exports2.PickResultType = exports2.QueuePicker = exports2.UnavailablePicker = exports2.ChildLoadBalancerHandler = exports2.EndpointMap = exports2.endpointHasAddress = exports2.endpointToString = exports2.subchannelAddressToString = exports2.LeafLoadBalancer = exports2.isLoadBalancerNameRegistered = exports2.parseLoadBalancingConfig = exports2.selectLbConfigFromList = exports2.registerLoadBalancerType = exports2.createChildChannelControlHelper = exports2.BackoffTimeout = exports2.durationToMs = exports2.splitHostPort = exports2.uriToString = exports2.createResolver = exports2.registerResolver = exports2.log = exports2.trace = void 0;
55803
57271
  var logging_1 = require_logging();
55804
57272
  Object.defineProperty(exports2, "trace", { enumerable: true, get: function() {
55805
57273
  return logging_1.trace;
@@ -55818,6 +57286,9 @@ var require_experimental = __commonJS({
55818
57286
  Object.defineProperty(exports2, "uriToString", { enumerable: true, get: function() {
55819
57287
  return uri_parser_1.uriToString;
55820
57288
  } });
57289
+ Object.defineProperty(exports2, "splitHostPort", { enumerable: true, get: function() {
57290
+ return uri_parser_1.splitHostPort;
57291
+ } });
55821
57292
  var duration_1 = require_duration();
55822
57293
  Object.defineProperty(exports2, "durationToMs", { enumerable: true, get: function() {
55823
57294
  return duration_1.durationToMs;
@@ -55889,6 +57360,10 @@ var require_experimental = __commonJS({
55889
57360
  Object.defineProperty(exports2, "BaseSubchannelWrapper", { enumerable: true, get: function() {
55890
57361
  return subchannel_interface_1.BaseSubchannelWrapper;
55891
57362
  } });
57363
+ var server_credentials_1 = require_server_credentials();
57364
+ Object.defineProperty(exports2, "createServerCredentialsWithInterceptors", { enumerable: true, get: function() {
57365
+ return server_credentials_1.createServerCredentialsWithInterceptors;
57366
+ } });
55892
57367
  }
55893
57368
  });
55894
57369
 
@@ -55919,6 +57394,7 @@ var require_resolver_uds = __commonJS({
55919
57394
  }
55920
57395
  }
55921
57396
  destroy() {
57397
+ this.hasReturnedResult = false;
55922
57398
  }
55923
57399
  static getDefaultAuthority(target) {
55924
57400
  return "localhost";
@@ -56085,6 +57561,9 @@ var require_load_balancer_round_robin = __commonJS({
56085
57561
  this.lastError = null;
56086
57562
  this.childChannelControlHelper = (0, load_balancer_1.createChildChannelControlHelper)(channelControlHelper, {
56087
57563
  updateState: (connectivityState, picker) => {
57564
+ if (this.currentState === connectivity_state_1.ConnectivityState.READY && connectivityState !== connectivity_state_1.ConnectivityState.READY) {
57565
+ this.channelControlHelper.requestReresolution();
57566
+ }
56088
57567
  this.calculateAndUpdateState();
56089
57568
  }
56090
57569
  });
@@ -56113,7 +57592,9 @@ var require_load_balancer_round_robin = __commonJS({
56113
57592
  } else if (this.countChildrenWithState(connectivity_state_1.ConnectivityState.CONNECTING) > 0) {
56114
57593
  this.updateState(connectivity_state_1.ConnectivityState.CONNECTING, new picker_1.QueuePicker(this));
56115
57594
  } else if (this.countChildrenWithState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE) > 0) {
56116
- this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({ details: `No connection established. Last error: ${this.lastError}` }));
57595
+ this.updateState(connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE, new picker_1.UnavailablePicker({
57596
+ details: `No connection established. Last error: ${this.lastError}`
57597
+ }));
56117
57598
  } else {
56118
57599
  this.updateState(connectivity_state_1.ConnectivityState.IDLE, new picker_1.QueuePicker(this));
56119
57600
  }
@@ -65353,7 +66834,7 @@ var require_sampling7 = __commonJS({
65353
66834
  });
65354
66835
 
65355
66836
  // node_modules/@opentelemetry/exporter-zipkin/node_modules/@opentelemetry/core/build/src/utils/environment.js
65356
- var require_environment13 = __commonJS({
66837
+ var require_environment14 = __commonJS({
65357
66838
  "node_modules/@opentelemetry/exporter-zipkin/node_modules/@opentelemetry/core/build/src/utils/environment.js"(exports2) {
65358
66839
  "use strict";
65359
66840
  Object.defineProperty(exports2, "__esModule", { value: true });
@@ -65558,12 +67039,12 @@ var require_environment13 = __commonJS({
65558
67039
  });
65559
67040
 
65560
67041
  // node_modules/@opentelemetry/exporter-zipkin/node_modules/@opentelemetry/core/build/src/platform/node/environment.js
65561
- var require_environment14 = __commonJS({
67042
+ var require_environment15 = __commonJS({
65562
67043
  "node_modules/@opentelemetry/exporter-zipkin/node_modules/@opentelemetry/core/build/src/platform/node/environment.js"(exports2) {
65563
67044
  "use strict";
65564
67045
  Object.defineProperty(exports2, "__esModule", { value: true });
65565
67046
  exports2.getEnvWithoutDefaults = exports2.getEnv = void 0;
65566
- var environment_1 = require_environment13();
67047
+ var environment_1 = require_environment14();
65567
67048
  function getEnv() {
65568
67049
  const processEnv = (0, environment_1.parseEnvironment)(process.env);
65569
67050
  return Object.assign({}, environment_1.DEFAULT_ENVIRONMENT, processEnv);
@@ -65732,7 +67213,7 @@ var require_node21 = __commonJS({
65732
67213
  };
65733
67214
  Object.defineProperty(exports2, "__esModule", { value: true });
65734
67215
  exports2.getEnv = exports2.getEnvWithoutDefaults = void 0;
65735
- var environment_1 = require_environment14();
67216
+ var environment_1 = require_environment15();
65736
67217
  Object.defineProperty(exports2, "getEnvWithoutDefaults", { enumerable: true, get: function() {
65737
67218
  return environment_1.getEnvWithoutDefaults;
65738
67219
  } });
@@ -66658,7 +68139,7 @@ var require_src34 = __commonJS({
66658
68139
  __exportStar(require_TraceIdRatioBasedSampler9(), exports2);
66659
68140
  __exportStar(require_suppress_tracing7(), exports2);
66660
68141
  __exportStar(require_TraceState7(), exports2);
66661
- __exportStar(require_environment13(), exports2);
68142
+ __exportStar(require_environment14(), exports2);
66662
68143
  __exportStar(require_merge7(), exports2);
66663
68144
  __exportStar(require_sampling7(), exports2);
66664
68145
  __exportStar(require_timeout7(), exports2);
@@ -67385,7 +68866,7 @@ var import_semantic_conventions = __toESM(require_src(), 1);
67385
68866
  import { getLogger } from "./request-context.cjs";
67386
68867
  var {
67387
68868
  default: { version, name }
67388
- } = await import("../../esm-chunks/package-GZ5FMVI4.js");
68869
+ } = await import("../../esm-chunks/package-EEQP43EX.js");
67389
68870
  var sdk = new import_sdk_node.NodeSDK({
67390
68871
  resource: new import_resources.Resource({
67391
68872
  [import_semantic_conventions.SEMRESATTRS_SERVICE_NAME]: name,