The service worker's proxy fallback only matched the wrapped "Offline"
error from HttpSpacePrimitives, but raw fetch() throws browser-native
errors like
"Failed to fetch" (Chrome), "NetworkError..." (Firefox), or "Load
failed"
(Safari). This caused a hard 503 instead of falling through to serve
local
data. Additionally, the `fullSyncConfirmed` flag reset on every service
worker
restart, forcing unnecessary proxying even when synced data existed in
IndexedDB.
In this commit:
- Use `isNetworkError()` in proxy_router.ts to catch all browser network
errors
and fall through to local serving instead of returning 503
* Recover `fullSyncConfirmed` from persisted sync snapshot on SW
restart, so
previously synced spaces serve locally immediately
* Adds e2e tests trying to emulate this behavior and prevent regressions
- New check for full indexing completion
- Renamed `hasInitialIndexCompleted` to `hasFullIndexCompleted` for clarity.
- Removed file:initial event (no longer required and not documented for public consumption)
Hopefully doesn't introduce new regressions. Needs testing time "in the field".
Service workers are a bit of a wild west: they can be killed at any time for any reason. This meant that a service worker (and with that a sync cycle) could be killed mid-sync, where files are already synced, but the _snapshot_ has not yet been persisted to the database. These changes persist the snapshot after ever single file sync operation (before: fully sync cycle), removing or at least lowering the chance of this happening. This can be a bit slower, but it's probably worth it.
accidentally writing to a read-only file and only finding out about it
after a sync.
Also removes redundant space primitive implementations that weren't used