@teincfood/core 0.9.21 → 0.9.22

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.
@@ -14,6 +14,7 @@ import { menuService, businessService, rolesService } from "../adapters/services
14
14
  import { cacheImageBatch, pruneImageCache } from "../adapters/image-cache";
15
15
  import { getConnectivityState } from "../adapters/connectivity";
16
16
  import { canBusinessSync } from "../sync/sync-guard";
17
+ import { getAuthToken } from "../adapters/auth";
17
18
  import { paceSync, isRateLimited } from "../sync/rate-limit";
18
19
  import { getReferenceData, getReferenceVersion, mergeReferenceData, writeServerReferenceData, } from "./operations";
19
20
  import { anchorServerTime } from "./entitlement-clock";
@@ -119,6 +120,18 @@ class ReferenceSyncService {
119
120
  catch (error) {
120
121
  result.failed.push(key);
121
122
  result.errors[key] = String(error);
123
+ // A persisted-but-expired session can pass `canBusinessSync` on the
124
+ // stale token; the first request then 401s and core's session
125
+ // lifecycle clears auth mid-pass. Every remaining key would just fail
126
+ // with "no authentication token" — abort quietly instead of emitting
127
+ // one error per key. Expected logout, not a sync fault.
128
+ if (!getAuthToken()) {
129
+ for (const remaining of keys.slice(keys.indexOf(key) + 1)) {
130
+ result.skipped.push(remaining);
131
+ }
132
+ syncLogger.warn("ReferenceSync", "Aborting sync — session ended mid-pass (logged out)", { key });
133
+ break;
134
+ }
122
135
  syncLogger.error("ReferenceSync", `Failed to sync ${key}`, {
123
136
  error: String(error),
124
137
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teincfood/core",
3
- "version": "0.9.21",
3
+ "version": "0.9.22",
4
4
  "description": "TeincFood shared offline-first core — types, sync engine, local DB, reference data, and repositories for mobile + desktop",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",