Skip to content

Commit

Permalink
fix(node): race condition rejects
Browse files Browse the repository at this point in the history
Rejecting the walletAddress import when a race condition occurs
  • Loading branch information
micahriggan committed Jan 8, 2019
1 parent e436459 commit d47ffb3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/bitcore-node/src/models/walletAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class WalletAddressModel extends BaseModel<IWalletAddress> {
const { chain, network } = wallet;

const unprocessedAddresses: Array<string> = [];
return new Promise(async resolve => {
return new Promise(async (resolve, reject) => {
for (let address of addresses) {
try {
const updatedAddress = await this.collection.findOneAndUpdate(
Expand All @@ -61,7 +61,7 @@ export class WalletAddressModel extends BaseModel<IWalletAddress> {
}
} catch (err) {
// Perhaps a race condition from multiple calls around the same time
console.error('Likely an upsert race condition in walletAddress updates');
reject('Likely an upsert race condition in walletAddress updates')
}
}

Expand Down

0 comments on commit d47ffb3

Please sign in to comment.