summaryrefslogtreecommitdiff
path: root/lib/domain.js
diff options
context:
space:
mode:
authorAndreas Madsen <amwebdk@gmail.com>2018-02-07 20:05:45 +0100
committerAndreas Madsen <amwebdk@gmail.com>2018-02-09 10:38:50 +0100
commit14bc3e22f3b2c34616091183fd431f39af6c2b65 (patch)
treedf3455bd0e33525c4e536655572f364769450395 /lib/domain.js
parentda97a47c4406d2c4bc867349dd039d6cc7cdff72 (diff)
downloadandroid-node-v8-14bc3e22f3b2c34616091183fd431f39af6c2b65.tar.gz
android-node-v8-14bc3e22f3b2c34616091183fd431f39af6c2b65.tar.bz2
android-node-v8-14bc3e22f3b2c34616091183fd431f39af6c2b65.zip
domain: runtime deprecate MakeCallback
Users of MakeCallback that adds the domain property to carry context, should start using the async_context variant of MakeCallback or the AsyncResource class. PR-URL: https://github.com/nodejs/node/pull/17417 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'lib/domain.js')
-rw-r--r--lib/domain.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/domain.js b/lib/domain.js
index 08fbd207f1..be109c9ce0 100644
--- a/lib/domain.js
+++ b/lib/domain.js
@@ -94,13 +94,29 @@ process.setUncaughtExceptionCaptureCallback = function(fn) {
throw err;
};
+
+let sendMakeCallbackDeprecation = false;
+function emitMakeCallbackDeprecation() {
+ if (!sendMakeCallbackDeprecation) {
+ process.emitWarning(
+ 'Using a domain property in MakeCallback is deprecated. Use the ' +
+ 'async_context variant of MakeCallback or the AsyncResource class ' +
+ 'instead.', 'DeprecationWarning', 'DEP0097');
+ sendMakeCallbackDeprecation = true;
+ }
+}
+
function topLevelDomainCallback(cb, ...args) {
const domain = this.domain;
+ if (exports.active && domain)
+ emitMakeCallbackDeprecation();
+
if (domain)
domain.enter();
const ret = Reflect.apply(cb, this, args);
if (domain)
domain.exit();
+
return ret;
}