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 f52a109 commit bd4e483
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 @@ -2392,12 +2392,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 @@ -2418,7 +2418,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 @@ -2445,6 +2444,11 @@ const transitionWalletToBat = () => {
return
}

if (!client) {
console.log('client error')
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 bd4e483

Please sign in to comment.