chore: increase update status RPC timeout and max attempts for bad network connection

This commit is contained in:
Siyuan 2025-11-18 13:46:02 +00:00
parent 7c79b3e514
commit 95be473608
1 changed files with 7 additions and 3 deletions

View File

@ -225,14 +225,17 @@ export interface SystemVersionInfo {
error?: string; error?: string;
} }
const UPDATE_STATUS_RPC_TIMEOUT_MS = 10000;
const UPDATE_STATUS_RPC_MAX_ATTEMPTS = 6;
export async function getUpdateStatus() { export async function getUpdateStatus() {
const response = await callJsonRpc<SystemVersionInfo>({ const response = await callJsonRpc<SystemVersionInfo>({
method: "getUpdateStatus", method: "getUpdateStatus",
// This function calls our api server to see if there are any updates available. // This function calls our api server to see if there are any updates available.
// It can be called on page load right after a restart, so we need to give it time to // It can be called on page load right after a restart, so we need to give it time to
// establish a connection to the api server. // establish a connection to the api server.
maxAttempts: 6, maxAttempts: UPDATE_STATUS_RPC_MAX_ATTEMPTS,
attemptTimeoutMs: 10000, attemptTimeoutMs: UPDATE_STATUS_RPC_TIMEOUT_MS,
}); });
if (response.error) throw response.error; if (response.error) throw response.error;
@ -253,13 +256,14 @@ export interface updateParams {
} }
export async function checkUpdateComponents(params: updateParams, includePreRelease: boolean) { export async function checkUpdateComponents(params: updateParams, includePreRelease: boolean) {
console.log("checkUpdateComponents", JSON.stringify(params, null, 2), includePreRelease);
const response = await callJsonRpc<SystemVersionInfo>({ const response = await callJsonRpc<SystemVersionInfo>({
method: "checkUpdateComponents", method: "checkUpdateComponents",
params: { params: {
params, params,
includePreRelease, includePreRelease,
}, },
maxAttempts: UPDATE_STATUS_RPC_MAX_ATTEMPTS,
attemptTimeoutMs: UPDATE_STATUS_RPC_TIMEOUT_MS,
}); });
if (response.error) throw response.error; if (response.error) throw response.error;
return response.result; return response.result;