Skip to content

Commit 280cd96

Browse files
addaleaxMylesBorins
authored andcommitted
domain: fix unintentional deprecation warning
646e5a4 changed the way that the domain hook callback is called. Previously, the callback was only used in the case that async_hooks were *not* being used (since domains already integrate with async hooks the way they should), and the corresponding deprecation warning also only emitted in that case. However, that commit didn’t move that condition along when the code was ported from C++ to JS. As a consequence, the domain hook callback was used when it wasn’t necessary to use it, and the deprecation warning emitted accidentally along with it. Refs: 646e5a4#diff-9f21ce1b9d6d46fdd07b969e8a04e140L192 Refs: 646e5a4#diff-e6db408e12db906ead6ddfac3de15a6fR119 Refs: #33801 (comment) PR-URL: #34245Fixes: #34069 Reviewed-By: Vladimir de Turckheim <vlad2t@hotmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
1 parent 3e3d908 commit 280cd96

6 files changed

Lines changed: 14 additions & 4 deletions

File tree

‎lib/internal/async_hooks.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,18 +112,18 @@ function useDomainTrampoline(fn) {
112112
}
113113

114114
functioncallbackTrampoline(asyncId,cb, ...args){
115-
if(asyncId&&hasHooks(kBefore))
115+
if(asyncId!==0&&hasHooks(kBefore))
116116
emitBeforeNative(asyncId);
117117

118118
letresult;
119-
if(typeofdomain_cb==='function'){
119+
if(asyncId===0&&typeofdomain_cb==='function'){
120120
ArrayPrototypeUnshift(args,cb);
121121
result=ReflectApply(domain_cb,this,args);
122122
}else{
123123
result=ReflectApply(cb,this,args);
124124
}
125125

126-
if(asyncId&&hasHooks(kAfter))
126+
if(asyncId!==0&&hasHooks(kAfter))
127127
emitAfterNative(asyncId);
128128

129129
returnresult;

‎test/parallel/test-domain-http-server.js‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@
2020
// USE OR OTHER DEALINGS IN THE SOFTWARE.
2121

2222
'use strict';
23-
require('../common');
23+
constcommon=require('../common');
2424
constdomain=require('domain');
2525
consthttp=require('http');
2626
constassert=require('assert');
2727
constdebug=require('util').debuglog('test');
2828

29+
process.on('warning',common.mustNotCall());
30+
2931
constobjects={foo: 'bar',baz: {},num: 42,arr: [1,2,3]};
3032
objects.baz.asdf=objects;
3133

‎test/parallel/test-domain-implicit-binding.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const domain = require('domain');
66
constfs=require('fs');
77
constisEnumerable=Function.call.bind(Object.prototype.propertyIsEnumerable);
88

9+
process.on('warning',common.mustNotCall());
10+
911
{
1012
constd=newdomain.Domain();
1113

‎test/parallel/test-domain-implicit-fs.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const common = require('../common');
2626
constassert=require('assert');
2727
constdomain=require('domain');
2828

29+
process.on('warning',common.mustNotCall());
30+
2931
constd=newdomain.Domain();
3032

3133
d.on('error',common.mustCall(function(er){

‎test/parallel/test-domain-multi.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ const common = require('../common');
2626
constdomain=require('domain');
2727
consthttp=require('http');
2828

29+
process.on('warning',common.mustNotCall());
30+
2931
consta=domain.create();
3032
a.enter();// This will be our "root" domain
3133

‎test/parallel/test-domain-promise.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const domain = require('domain');
55
constfs=require('fs');
66
constvm=require('vm');
77

8+
process.on('warning',common.mustNotCall());
9+
810
{
911
constd=domain.create();
1012

0 commit comments

Comments
 (0)