fix(@desktop/general): crash during profile keypair migration
Happens occasionally that the app crashes during the profile keypair migration flow. It happens cause during that flow in one moment the app gets locked, cause encryption gets changed, but some parts of the app may still try to get some data from the db (as an action for some async event or so). That action results as the app crash. In such cases an exception will be thrown, but it needs to be handled in functions which are doing a call. `fetchAccounts` is guarded in this commit, cause crash was initiated there, cause it didn't handle a call appropriately using try/catch block.
This commit is contained in:
parent
6936782736
commit
bf34239813
|
@ -701,6 +701,8 @@ QtObject:
|
|||
hashedCurrentPassword: hashedCurrentPassword,
|
||||
newPassword: newPassword
|
||||
)
|
||||
|
||||
DB_BLOCKED_DUE_TO_PROFILE_MIGRATION = true
|
||||
self.threadpool.start(arg)
|
||||
|
||||
proc onConvertToKeycardAccount*(self: Service, response: string) {.slot.} =
|
||||
|
|
|
@ -153,10 +153,13 @@ QtObject:
|
|||
result.walletAccounts = initOrderedTable[string, WalletAccountDto]()
|
||||
|
||||
proc fetchAccounts*(self: Service): seq[WalletAccountDto] =
|
||||
let response = status_go_accounts.getAccounts()
|
||||
return response.result.getElems().map(
|
||||
x => x.toWalletAccountDto()
|
||||
).filter(a => not a.isChat)
|
||||
try:
|
||||
let response = status_go_accounts.getAccounts()
|
||||
return response.result.getElems().map(
|
||||
x => x.toWalletAccountDto()
|
||||
).filter(a => not a.isChat)
|
||||
except Exception as e:
|
||||
error "error: ", procName="fetchAccounts", errName = e.name, errDesription = e.msg
|
||||
|
||||
proc setEnsName(self: Service, account: WalletAccountDto) =
|
||||
let chainId = self.networkService.getNetworkForEns().chainId
|
||||
|
|
|
@ -7,6 +7,10 @@ export response_type
|
|||
logScope:
|
||||
topics = "rpc"
|
||||
|
||||
## we guard majority db calls which may occure during Profile KeyPair migration
|
||||
## (if there is a need we can guard other non rpc calls as well in the same way)
|
||||
var DB_BLOCKED_DUE_TO_PROFILE_MIGRATION* = false
|
||||
|
||||
proc callRPC*(inputJSON: string): string =
|
||||
return $status_go.callRPC(inputJSON)
|
||||
|
||||
|
@ -16,6 +20,9 @@ proc callPrivateRPCRaw*(inputJSON: string): string {.raises: [].} =
|
|||
proc makePrivateRpcCall*(
|
||||
methodName: string, inputJSON: JsonNode
|
||||
): RpcResponse[JsonNode] {.raises: [RpcException, ValueError, Defect, SerializationError].} =
|
||||
if DB_BLOCKED_DUE_TO_PROFILE_MIGRATION:
|
||||
debug "DB blocked due to profile migration, unable to proceed with the rpc call", rpc_method=methodName
|
||||
raise newException(RpcException, "db closed due to profile migration")
|
||||
try:
|
||||
debug "NewBE_callPrivateRPC", rpc_method=methodName
|
||||
let rpcResponseRaw = status_go.callPrivateRPC($inputJSON)
|
||||
|
|
Loading…
Reference in New Issue