Refuse to open the database without Web Locks

Without them nothing can promise a second tab won't open a second SQLite
over the same pages. Refusing with a clear message beats hoping; the
browsers affected (iOS Safari < 15.4, Android Chrome < 69) are already
behind what the app needs.
This commit is contained in:
Gregory Schier
2026-08-15 16:33:31 -07:00
parent 7c8ee57d1d
commit a5c0eb4c1d
+10 -3
View File
@@ -71,9 +71,16 @@ const ALREADY_OPEN =
*/
function acquireDatabaseLock(): Promise<void> {
if (typeof navigator.locks === "undefined") {
// No way to guarantee exclusivity; proceed and hope. This is old browsers
// only, and they will get one tab working.
return Promise.resolve();
// Without Web Locks there is no way to promise a second tab won't open a
// second SQLite over the same pages, and a hopeful open is a corrupted
// workspace waiting to happen. Refuse. This is iOS Safari before 15.4 and
// Android Chrome before 69 — browsers the rest of the app has already
// left behind.
return Promise.reject(
new Error(
"This browser can't keep Yaak's data safe when more than one tab is open (it has no Web Locks). Please use a newer browser.",
),
);
}
return new Promise<void>((resolve, reject) => {
navigator.locks