@openfeature/flagd-provider 0.8.0 → 0.8.1

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.
package/index.cjs CHANGED
@@ -5888,7 +5888,9 @@ class GRPCService {
5888
5888
  disconnect() {
5889
5889
  var _a;
5890
5890
  return __awaiter(this, void 0, void 0, function* () {
5891
- (_a = this._stream) === null || _a === void 0 ? void 0 : _a.destroy();
5891
+ // cancel the stream and close the connection
5892
+ (_a = this._stream) === null || _a === void 0 ? void 0 : _a.cancel();
5893
+ this._client.close();
5892
5894
  });
5893
5895
  }
5894
5896
  resolveBoolean(flagKey, context, logger) {
@@ -5915,9 +5917,15 @@ class GRPCService {
5915
5917
  return new Promise((resolve, reject) => {
5916
5918
  var _a;
5917
5919
  (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`${FlagdProvider.name}: connecting stream, attempt ${this._streamConnectAttempt}...`);
5918
- const stream = this._client.eventStream({});
5919
- stream.on('error', () => {
5920
- this.handleError(reject, connectCallback, changedCallback, disconnectCallback);
5920
+ const stream = this._client.eventStream({}, {});
5921
+ stream.on('error', (err) => {
5922
+ var _a;
5923
+ if ((err === null || err === void 0 ? void 0 : err.code) === grpcJs.status.CANCELLED) {
5924
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`${FlagdProvider.name}: stream cancelled, will not be re-established`);
5925
+ }
5926
+ else {
5927
+ this.handleError(reject, connectCallback, changedCallback, disconnectCallback);
5928
+ }
5921
5929
  });
5922
5930
  stream.on('close', () => {
5923
5931
  this.handleClose();
package/index.js CHANGED
@@ -5884,7 +5884,9 @@ class GRPCService {
5884
5884
  disconnect() {
5885
5885
  var _a;
5886
5886
  return __awaiter(this, void 0, void 0, function* () {
5887
- (_a = this._stream) === null || _a === void 0 ? void 0 : _a.destroy();
5887
+ // cancel the stream and close the connection
5888
+ (_a = this._stream) === null || _a === void 0 ? void 0 : _a.cancel();
5889
+ this._client.close();
5888
5890
  });
5889
5891
  }
5890
5892
  resolveBoolean(flagKey, context, logger) {
@@ -5911,9 +5913,15 @@ class GRPCService {
5911
5913
  return new Promise((resolve, reject) => {
5912
5914
  var _a;
5913
5915
  (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`${FlagdProvider.name}: connecting stream, attempt ${this._streamConnectAttempt}...`);
5914
- const stream = this._client.eventStream({});
5915
- stream.on('error', () => {
5916
- this.handleError(reject, connectCallback, changedCallback, disconnectCallback);
5916
+ const stream = this._client.eventStream({}, {});
5917
+ stream.on('error', (err) => {
5918
+ var _a;
5919
+ if ((err === null || err === void 0 ? void 0 : err.code) === status.CANCELLED) {
5920
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.debug(`${FlagdProvider.name}: stream cancelled, will not be re-established`);
5921
+ }
5922
+ else {
5923
+ this.handleError(reject, connectCallback, changedCallback, disconnectCallback);
5924
+ }
5917
5925
  });
5918
5926
  stream.on('close', () => {
5919
5927
  this.handleClose();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfeature/flagd-provider",
3
- "version": "0.8.0",
3
+ "version": "0.8.1",
4
4
  "scripts": {
5
5
  "publish-if-not-exists": "cp $NPM_CONFIG_USERCONFIG .npmrc && if [ \"$(npm show $npm_package_name@$npm_package_version version)\" = \"$(npm run current-version -s)\" ]; then echo 'already published, skipping'; else npm publish --access public; fi",
6
6
  "current-version": "echo $npm_package_version"
@@ -2,7 +2,7 @@ import { EvaluationContext, JsonValue, Logger, OpenFeatureEventEmitter, Provider
2
2
  import { FlagdProviderOptions } from './configuration';
3
3
  import { Service } from './service/service';
4
4
  export declare class FlagdProvider implements Provider {
5
- private logger?;
5
+ private readonly logger?;
6
6
  metadata: {
7
7
  name: string;
8
8
  };