@scalemule/nextjs 0.0.14 → 0.0.16

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.
@@ -1794,7 +1794,12 @@ async function getFlagClient(environment) {
1794
1794
  if (pending) return pending;
1795
1795
  const promise = (async () => {
1796
1796
  const client = new server$1.FlagClient({ apiKey, environment, gatewayUrl });
1797
- await client.init();
1797
+ await Promise.race([
1798
+ client.init(),
1799
+ new Promise(
1800
+ (_, reject) => setTimeout(() => reject(new Error("FlagClient init timeout")), 3e3)
1801
+ )
1802
+ ]);
1798
1803
  _clients.set(key, client);
1799
1804
  return client;
1800
1805
  })();
@@ -1810,10 +1815,12 @@ var _shutdownRegistered = false;
1810
1815
  function ensureShutdownHook() {
1811
1816
  if (_shutdownRegistered) return;
1812
1817
  _shutdownRegistered = true;
1813
- process.once("SIGTERM", async () => {
1814
- const shutdowns = Array.from(_clients.values()).map((c) => c.shutdown());
1815
- await Promise.allSettled(shutdowns);
1816
- });
1818
+ if (typeof process !== "undefined" && typeof process.once === "function") {
1819
+ process.once("SIGTERM", async () => {
1820
+ const shutdowns = Array.from(_clients.values()).map((c) => c.shutdown());
1821
+ await Promise.allSettled(shutdowns);
1822
+ });
1823
+ }
1817
1824
  }
1818
1825
  function extractClientIp(hdrs) {
1819
1826
  const realIp = hdrs.get("x-real-ip") || hdrs.get("x-real-client-ip");
@@ -1792,7 +1792,12 @@ async function getFlagClient(environment) {
1792
1792
  if (pending) return pending;
1793
1793
  const promise = (async () => {
1794
1794
  const client = new FlagClient({ apiKey, environment, gatewayUrl });
1795
- await client.init();
1795
+ await Promise.race([
1796
+ client.init(),
1797
+ new Promise(
1798
+ (_, reject) => setTimeout(() => reject(new Error("FlagClient init timeout")), 3e3)
1799
+ )
1800
+ ]);
1796
1801
  _clients.set(key, client);
1797
1802
  return client;
1798
1803
  })();
@@ -1808,10 +1813,12 @@ var _shutdownRegistered = false;
1808
1813
  function ensureShutdownHook() {
1809
1814
  if (_shutdownRegistered) return;
1810
1815
  _shutdownRegistered = true;
1811
- process.once("SIGTERM", async () => {
1812
- const shutdowns = Array.from(_clients.values()).map((c) => c.shutdown());
1813
- await Promise.allSettled(shutdowns);
1814
- });
1816
+ if (typeof process !== "undefined" && typeof process.once === "function") {
1817
+ process.once("SIGTERM", async () => {
1818
+ const shutdowns = Array.from(_clients.values()).map((c) => c.shutdown());
1819
+ await Promise.allSettled(shutdowns);
1820
+ });
1821
+ }
1815
1822
  }
1816
1823
  function extractClientIp(hdrs) {
1817
1824
  const realIp = hdrs.get("x-real-ip") || hdrs.get("x-real-client-ip");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalemule/nextjs",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "ScaleMule SDK for Next.js applications - authentication, storage, and user management",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -52,7 +52,7 @@
52
52
  "clean": "rm -rf dist"
53
53
  },
54
54
  "dependencies": {
55
- "@scalemule/sdk": "^0.0.14"
55
+ "@scalemule/sdk": "^0.0.15"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "next": ">=14.0.0",