@snokam/auth 6.3.16 → 6.3.18

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/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [6.3.18](https://github.com/snokam/components/compare/%40snokam%2Fauth%406.3.17...%40snokam%2Fauth%406.3.18) (2026-11-14)
7
+
8
+ ### Bug Fixes
9
+
10
+ - **auth:** stop registration button hanging forever if a stalled reload sticks ([#3725](https://github.com/snokam/components/issues/3725)) ([aafb42f](https://github.com/snokam/components/commit/aafb42f5fc0f40e369f8fe5dc793443afe380f06))
11
+
12
+ ## [6.3.17](https://github.com/snokam/components/compare/%40snokam%2Fauth%406.3.16...%40snokam%2Fauth%406.3.17) (2026-11-14)
13
+
14
+ **Note:** Version bump only for package @snokam/auth
15
+
6
16
  ## [6.3.16](https://github.com/snokam/components/compare/%40snokam%2Fauth%406.3.15...%40snokam%2Fauth%406.3.16) (2026-11-14)
7
17
 
8
18
  **Note:** Version bump only for package @snokam/auth
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@snokam/auth",
3
3
  "description": "Snøkam auth components",
4
- "version": "6.3.16",
4
+ "version": "6.3.18",
5
5
  "main": "src/index.ts",
6
6
  "sideEffects": false,
7
7
  "types": "src/index.ts",
@@ -27,11 +27,11 @@
27
27
  "next-auth": "4.24.15",
28
28
  "path-to-regexp": "^9.0.0",
29
29
  "@snokam/identity": "1.1.1",
30
- "@snokam/api-client": "1.0.0",
31
- "@snokam/page-content": "6.12.13",
30
+ "@snokam/page-content": "6.12.14",
32
31
  "@snokam/react-query": "1.1.3",
33
32
  "@snokam/tenant": "4.5.8",
34
- "@snokam/ui": "7.11.4"
33
+ "@snokam/ui": "7.11.5",
34
+ "@snokam/api-client": "1.0.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "next": "16.4.5",
@@ -108,6 +108,23 @@ describe("a Vis som session that ends or changes under the page", () => {
108
108
  assert.equal(state.reloads, 1);
109
109
  });
110
110
 
111
+ it("self-heals from a reloading flag stuck by a page.reload() that never unloaded the page", async () => {
112
+ const { clean } = page();
113
+ const watch = watchSession("imp-1", clean);
114
+
115
+ assert.equal(watch.observe(null), false);
116
+ assert.equal(watch.isReloading(), true);
117
+
118
+ const realNow = Date.now;
119
+ const longAfterARealReloadWouldHaveUnloadedThePage = realNow() + 5000;
120
+ Date.now = () => longAfterARealReloadWouldHaveUnloadedThePage;
121
+ try {
122
+ assert.equal(watch.isReloading(), false);
123
+ } finally {
124
+ Date.now = realNow;
125
+ }
126
+ });
127
+
111
128
  it("never reloads twice for the same change, so a reload cannot loop", () => {
112
129
  const first = page();
113
130
  watchSession("imp-1", first.clean).observe(null);
@@ -11,6 +11,8 @@ export interface SessionWatch {
11
11
  isReloading: () => boolean;
12
12
  }
13
13
 
14
+ const REAL_RELOAD_UNLOADS_WITHIN_MS = 3000;
15
+
14
16
  export function watchSession(
15
17
  initialTokenId: string | null,
16
18
  page: CleanPage
@@ -19,6 +21,7 @@ export function watchSession(
19
21
  let settled = initialTokenId !== null;
20
22
  let paused = false;
21
23
  let reloading = false;
24
+ let reloadingSince = 0;
22
25
 
23
26
  const startClean = (next: string | null): boolean => {
24
27
  const change = `${known ?? ""}>${next ?? ""}`;
@@ -26,11 +29,22 @@ export function watchSession(
26
29
  if (page.lastReload() === change) return true;
27
30
  page.rememberReload(change);
28
31
  reloading = true;
32
+ reloadingSince = Date.now();
29
33
  page.reload();
30
34
  return false;
31
35
  };
32
36
 
37
+ const recoverFromStalledReload = (): void => {
38
+ if (
39
+ reloading &&
40
+ Date.now() - reloadingSince > REAL_RELOAD_UNLOADS_WITHIN_MS
41
+ ) {
42
+ reloading = false;
43
+ }
44
+ };
45
+
33
46
  const observe = (tokenId: string | null): boolean => {
47
+ recoverFromStalledReload();
34
48
  if (paused || reloading) return false;
35
49
  const firstRead = !settled;
36
50
  settled = true;
@@ -48,6 +62,9 @@ export function watchSession(
48
62
  resume: () => {
49
63
  paused = false;
50
64
  },
51
- isReloading: () => reloading,
65
+ isReloading: () => {
66
+ recoverFromStalledReload();
67
+ return reloading;
68
+ },
52
69
  };
53
70
  }