From 309d616afe78c42af1a326b1931e07471d47a8be Mon Sep 17 00:00:00 2001 From: Rizky Date: Fri, 12 Jul 2024 19:43:40 +0700 Subject: [PATCH] fix reconnecting... --- app/web/src/nova/ed/logic/ed-sync.tsx | 10 +++++----- app/web/src/utils/sync/ws-client.ts | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/web/src/nova/ed/logic/ed-sync.tsx b/app/web/src/nova/ed/logic/ed-sync.tsx index ff57d132..265c2716 100644 --- a/app/web/src/nova/ed/logic/ed-sync.tsx +++ b/app/web/src/nova/ed/logic/ed-sync.tsx @@ -1,17 +1,17 @@ +import { createRouter, RadixRouter } from "radix3"; import { compress, decompress } from "wasm-gzip"; import { deepClone } from "web-utils"; import * as Y from "yjs"; +import { registerSiteTypings } from "../../../utils/script/typings"; import { clientStartSync } from "../../../utils/sync/ws-client"; import { w } from "../../../utils/types/general"; import { Loading } from "../../../utils/ui/loading"; +import { loadFrontEnd, loadTypings } from "./code-loader"; +import { updateComponentMeta } from "./comp/load"; import { EmptySite, PG } from "./ed-global"; -import { treeRebuild } from "./tree/build"; import { reloadPage } from "./ed-route"; import { loadSite } from "./ed-site"; -import { updateComponentMeta } from "./comp/load"; -import { createRouter, RadixRouter } from "radix3"; -import { loadCode, loadFrontEnd, loadTypings } from "./code-loader"; -import { registerSiteTypings } from "../../../utils/script/typings"; +import { treeRebuild } from "./tree/build"; const decoder = new TextDecoder(); diff --git a/app/web/src/utils/sync/ws-client.ts b/app/web/src/utils/sync/ws-client.ts index 4b12a98c..7b36f414 100644 --- a/app/web/src/utils/sync/ws-client.ts +++ b/app/web/src/utils/sync/ws-client.ts @@ -165,7 +165,13 @@ const connect = ( `${url.protocol}//${url.host}${url.pathname}` ); + const timeout = setTimeout(() => { + ws.close(); + retry(); + }, 2000); + ws.onopen = () => { + clearTimeout(timeout); w.offline = false; w.editorRender?.();