Skip to content

Commit

Permalink
style(db_util): add link on why "ensureAsync" is needed
Browse files Browse the repository at this point in the history
  • Loading branch information
hasezoey committed Oct 12, 2020
1 parent 9add2bc commit 412e615
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions packages/mongodb-memory-server-core/src/util/db_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export async function killProcess(childprocess: ChildProcess, name: string): Pro

/**
* Call "setImmediate" to ensure an function is exectued on next event loop
* look at the following link to get to know on why this needed: https://snyk.io/blog/nodejs-how-even-quick-async-functions-can-block-the-event-loop-starve-io/
*/
export async function ensureAsync(): Promise<void> {
return new Promise((res) => setImmediate(res));
Expand Down

0 comments on commit 412e615

Please sign in to comment.