Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: add 2 seconds delay for reconnecting after PC becomes online

thecodrr776121bcff8c
diff --git a/apps/web/src/stores/user-store.js b/apps/web/src/stores/user-store.js
index 29d86b680..b14c16af1 100644
--- a/apps/web/src/stores/user-store.js
+++ b/apps/web/src/stores/user-store.js
@@ -81,6 +81,11 @@ class UserStore extends BaseStore {
onPageVisibilityChanged(async function (type, documentHidden) {
if (!documentHidden) {
+ if (type === "online") {
+ // a slight delay to make sure sockets are open and can be connected
+ // to. Otherwise, this fails miserably.
+ await new Promise((resolve) => setTimeout(resolve, 2000));
+ }
await db
.connectSSE({ force: type === "online" })
.catch(console.error);