From de947acc0f541a64cb94317101808e228674feec Mon Sep 17 00:00:00 2001 From: vet Date: Tue, 14 Apr 2026 12:53:51 +0700 Subject: [PATCH] test --- pc-sdk-probe.sh | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/pc-sdk-probe.sh b/pc-sdk-probe.sh index 78aca6c..c271ae8 100755 --- a/pc-sdk-probe.sh +++ b/pc-sdk-probe.sh @@ -32,7 +32,7 @@ cat <<'EOF' console.log(`[probe] ${name}: wrapped`); }; - ["initSDK", "login", "commonEventFunc"].forEach(wrap); + ["initSDK", "login", "commonEventFunc", "initDB", "setSqlWasmPath"].forEach(wrap); window.addEventListener("error", (event) => { console.error("[probe window error]", event.message, event.filename, event.lineno, event.error); }); @@ -45,6 +45,8 @@ cat <<'EOF' initSDK: typeof window.initSDK, login: typeof window.login, commonEventFunc: typeof window.commonEventFunc, + initDB: typeof window.initDB, + setSqlWasmPath: typeof window.setSqlWasmPath, openIMRenderApi: typeof window.openIMRenderApi, }); window.__deployTestProbeCounts = counts; @@ -184,6 +186,20 @@ cat <<'EOF' console.log(`[probe ${stamp()}] manual login result`, result); return result; }; + window.__deployTestManualInitDB = async (userID) => { + userID = userID || await window.__deployTestReadLocalForage("IM_USERID") || "6087132211"; + console.log(`[probe ${stamp()}] manual setSqlWasmPath`, "/sql-wasm.wasm"); + if (typeof window.setSqlWasmPath === "function") { + await window.setSqlWasmPath("/sql-wasm.wasm"); + } + console.log(`[probe ${stamp()}] manual initDB start`, { userID, dataDir: "./" }); + const timeout = new Promise((_, reject) => { + setTimeout(() => reject(new Error("manual window.initDB timeout after 15000ms")), 15000); + }); + const result = await Promise.race([window.initDB(String(userID), "./"), timeout]); + console.log(`[probe ${stamp()}] manual initDB result`, result); + return result; + }; clearInterval(window.__deployTestProbeTimer); window.__deployTestProbeTimer = setInterval(() => { console.log(`[probe ${stamp()}] counts`, { ...counts }); @@ -191,8 +207,7 @@ cat <<'EOF' })(); 然后退出登录/刷新页面重新登录一次,观察是否打印: -- initSDK called / returned -- login called / returned +- initSDK / login / initDB / setSqlWasmPath called / returned - window error / unhandledrejection - counts 里的 initSDK/login 是否从 0 变成 1 @@ -212,6 +227,10 @@ window.__deployTestManualLogin({ await window.__deployTestListBrowserDBs() await window.__deployTestResetBrowserStorage() +也可以单独测试 initDB: + +await window.__deployTestManualInitDB() + 清理后按这个顺序重测: 1. 关闭其它 http://54.116.29.247:5173 标签页 2. 刷新页面