This commit is contained in:
vet
2026-04-14 12:53:51 +07:00
parent 5412d592f3
commit de947acc0f

View File

@@ -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. 刷新页面