@razakalpha/convngx 0.2.2 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razakalpha/convngx",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "peerDependencies": {
5
5
  "@angular/common": "^20.1.0",
6
6
  "@angular/core": "^20.1.0",
@@ -12,7 +12,7 @@
12
12
  "tslib": "^2.3.0"
13
13
  },
14
14
  "sideEffects": false,
15
- "module": "fesm2022/RazakAlpha-convngx.mjs",
15
+ "module": "fesm2022/razakalpha-convngx.mjs",
16
16
  "typings": "index.d.ts",
17
17
  "exports": {
18
18
  "./package.json": {
@@ -20,7 +20,7 @@
20
20
  },
21
21
  ".": {
22
22
  "types": "./index.d.ts",
23
- "default": "./fesm2022/RazakAlpha-convngx.mjs"
23
+ "default": "./fesm2022/razakalpha-convngx.mjs"
24
24
  }
25
25
  }
26
26
  }
@@ -47,8 +47,29 @@ export function provideConvexBetterAuth(opts: ConvexBetterAuthOptions): Provider
47
47
 
48
48
  const fetchAccessToken: FetchAccessToken = async ({ forceRefreshToken }) => {
49
49
  if (!forceRefreshToken) return null;
50
- const { data } = await auth.convex.token();
51
- return data?.token ?? null;
50
+
51
+ // Retry logic for transient failures (e.g., session not fully propagated)
52
+ let lastError: any;
53
+ for (let attempt = 0; attempt < 3; attempt++) {
54
+ try {
55
+ if (attempt > 0) {
56
+ // Wait before retry: 50ms, then 100ms
57
+ const delay = attempt * 50;
58
+ await new Promise((resolve) => setTimeout(resolve, delay));
59
+ }
60
+
61
+ const { data } = await auth.convex.token();
62
+ return data?.token ?? null;
63
+ } catch (err: any) {
64
+ lastError = err;
65
+ // Only retry on "Failed to fetch" errors
66
+ if (attempt < 2 && err?.message === 'Failed to fetch') {
67
+ continue;
68
+ }
69
+ throw err;
70
+ }
71
+ }
72
+ throw lastError;
52
73
  };
53
74
 
54
75
  client.setAuth(fetchAccessToken);