Skip to content

Commit

Permalink
fix(ref-imp): updated mongodb lib version in attempt to fix rare DB i…
Browse files Browse the repository at this point in the history
…nfinite awaits
  • Loading branch information
thehenrytsai committed Mar 15, 2021
1 parent 54509a5 commit 9fc1f1c
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 92 deletions.
4 changes: 2 additions & 2 deletions lib/bitcoin/MongoDbBlockMetadataStore.ts
Expand Up @@ -66,7 +66,7 @@ export default class MongoDbBlockMetadataStore extends MongoDbStore implements I
}

public async getLast (): Promise<BlockMetadata | undefined> {
const blocks = await this.collection!.find<BlockMetadata>().sort({ height: -1 }).limit(1).toArray();
const blocks = await this.collection!.find().sort({ height: -1 }).limit(1).toArray();
if (blocks.length === 0) {
return undefined;
}
Expand All @@ -79,7 +79,7 @@ export default class MongoDbBlockMetadataStore extends MongoDbStore implements I
* Gets the first block (block with lowest height).
*/
private async getFirst (): Promise<BlockMetadata | undefined> {
const blocks = await this.collection!.find<BlockMetadata>().sort({ height: 1 }).limit(1).toArray();
const blocks = await this.collection!.find().sort({ height: 1 }).limit(1).toArray();
if (blocks.length === 0) {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/common/MongoDbServiceStateStore.ts
Expand Up @@ -21,7 +21,7 @@ export default class MongoDbServiceStateStore<T> extends MongoDbStore implements

public async get (): Promise<T | undefined> {
const queryOptions = { fields: { _id: 0 } }; // Exclude `_id` field from being returned.
const serviceState = await this.collection!.findOne<T>({ }, queryOptions); //
const serviceState = await this.collection!.findOne({ }, queryOptions);

if (serviceState === null) {
return undefined;
Expand Down

0 comments on commit 9fc1f1c

Please sign in to comment.