Skip to content

Commit

Permalink
Fixes undefined scenarious
Browse files Browse the repository at this point in the history
Resolves brave#11703
Resolves brave#11684

Auditors:

Test Plan:
  • Loading branch information
NejcZdovc committed Nov 6, 2017
1 parent 88974f2 commit 3255d9c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -2394,12 +2394,12 @@ const transitionWalletToBat = () => {
let newPaymentId, result

if (newClient === true) return
clientprep()

// Restore newClient from the file
if (!newClient) {
const fs = require('fs')
try {
clientprep()
fs.accessSync(pathName(newClientPath), fs.FF_OK)
fs.readFile(pathName(newClientPath), (error, data) => {
if (error) {
Expand All @@ -2420,7 +2420,6 @@ const transitionWalletToBat = () => {
// Create new client
if (!newClient) {
try {
clientprep()
newClient = ledgerClient(null, underscore.extend({roundtrip: roundtrip}, clientOptions), null)
muonWriter(newClientPath, newClient.state)
} catch (ex) {
Expand All @@ -2447,6 +2446,11 @@ const transitionWalletToBat = () => {
return
}

if (!client) {
console.log('Client is not initialized, will try again')
return
}

if (client.busyP()) {
console.log('ledger client is currently busy; transition will be retried on next launch')
return
Expand Down

0 comments on commit 3255d9c

Please sign in to comment.