Skip to content

Commit

Permalink
Added call to nextTick in TaskQueue to make sure queue is handled async.
Browse files Browse the repository at this point in the history
  • Loading branch information
meirgottlieb committed Apr 4, 2018
1 parent bba143a commit 5bfb0a9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "hydrate-mongodb",
"description": "An Object Document Mapper (ODM) for MongoDB.",
"version": "2.0.2",
"version": "2.0.3",
"author": {
"name": "Artifact Health, LLC",
"url": "http://www.artifacthealth.com"
Expand Down
4 changes: 3 additions & 1 deletion src/taskQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export class TaskQueue extends EventEmitter {
else {
// this is the first task so initialize the queue and start processing
this._head = this._tail = task;
// make sure calls to _process are async
process.nextTick(() => this._process());
}
}
Expand Down Expand Up @@ -144,7 +145,8 @@ export class TaskQueue extends EventEmitter {
}

if(this._head) {
this._process();
// make sure calls to _process are async
process.nextTick(() => this._process());
}

}
Expand Down
2 changes: 1 addition & 1 deletion tests/driver/mockCursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class MockCursor extends Readable implements mongodb.Cursor {
next(): Promise<any>;
next(callback: mongodb.MongoCallback<any>): void;
next(callback?: any): any {

callback();
}

project(value: Object): mongodb.Cursor<any> {
Expand Down

0 comments on commit 5bfb0a9

Please sign in to comment.