Skip to content

Commit de4af05

Browse files
committed
setImmediate over next tick.
1 parent ce7fa35 commit de4af05

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# Dependency directories
88
node_modules
99

10+
dist
11+
1012
# Optional npm cache directory
1113
.npm
1214

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 2.0.7 (December 20, 2020)
4+
5+
- Preferring `setImmediate` over `nextTick`.
6+
37
## 2.0.6 (December 2, 2020)
48

59
- Better types definition for get.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-execution-context",
3-
"version": "2.0.6",
3+
"version": "2.0.7",
44
"description": "Provides execution context wrapper for node JS, can be used to create execution wrapper for handling requests and more",
55
"author": "Oded Goldglas <odedglas@gmail.com>",
66
"license": "ISC",

src/hooks/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ const getContextRef = (parentContext, triggerAsyncId) => (
1111
);
1212

1313
/**
14-
* Suspends a given f unction execution over process next tick.
14+
* Suspends a given function execution over process next tick.
1515
* @param {Function} fn - The function to trigger upon next tick.
1616
* @param {...any} args - The function arguments to trigger with.
1717
* @return {any}
1818
*/
19-
const suspend = (fn, ...args) => process.nextTick(() => fn(...args));
19+
const suspend = (fn, ...args) => setImmediate(() => fn(...args));
2020

2121
/**
2222
* The "async_hooks" init hook callback, used to initialize sub process of the main context

src/hooks/spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ describe('Context / Hooks', () => {
114114

115115
destroy(triggerAsyncId);
116116

117-
process.nextTick(() => {
117+
setImmediate(() => {
118118
expect(executionMap.get(triggerAsyncId)).toBeUndefined();
119119
expect(spies.contextMapDelete).toHaveBeenCalledWith(triggerAsyncId);
120120

@@ -142,7 +142,7 @@ describe('Context / Hooks', () => {
142142
const [ firstChild ] = children;
143143
destroy(firstChild);
144144

145-
process.nextTick(() => {
145+
setImmediate(() => {
146146
expect(spies.contextMapDelete).toHaveBeenCalledWith(firstChild);
147147

148148
done();

0 commit comments

Comments
 (0)