@rpcbase/client 0.312.0 → 0.313.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"getFeatureFlag.d.ts","sourceRoot":"","sources":["../src/getFeatureFlag.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,KACX,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,SAAS,CAuDtC,CAAA"}
1
+ {"version":3,"file":"getFeatureFlag.d.ts","sourceRoot":"","sources":["../src/getFeatureFlag.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,KACX,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,SAAS,CA8DtC,CAAA"}
package/dist/index.js CHANGED
@@ -857,12 +857,16 @@ const getFeatureFlag = async (flag) => {
857
857
  return value;
858
858
  } else {
859
859
  let waitForFeatureFlags = function() {
860
- return new Promise((resolve) => {
860
+ return new Promise((resolve, reject) => {
861
861
  if (hasLoadedFeatureFlags) {
862
862
  resolve();
863
863
  } else {
864
+ const timeout = setTimeout(() => {
865
+ reject(new Error(`PostHog feature flags did not load within ${TIMEOUT_MS}ms`));
866
+ }, TIMEOUT_MS);
864
867
  posthog2.onFeatureFlags(() => {
865
868
  hasLoadedFeatureFlags = true;
869
+ clearTimeout(timeout);
866
870
  resolve();
867
871
  });
868
872
  }
@@ -874,6 +878,7 @@ const getFeatureFlag = async (flag) => {
874
878
  const startTime = performance.now();
875
879
  const { posthog: posthog2 } = await import("posthog-js");
876
880
  let hasLoadedFeatureFlags = false;
881
+ const TIMEOUT_MS = 8e3;
877
882
  await waitForFeatureFlags();
878
883
  const endTime = performance.now();
879
884
  console.log(`Client: Feature flag "${flag}" loaded in ${(endTime - startTime).toFixed(2)}ms`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/client",
3
- "version": "0.312.0",
3
+ "version": "0.313.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"