Skip to content

Commit 9230f22

Browse files
authored
process: remove support for undocumented symbol
PR-URL: #56552 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent c61504b commit 9230f22

2 files changed

Lines changed: 6 additions & 21 deletions

File tree

‎lib/internal/process/per_thread.js‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -420,15 +420,17 @@ function toggleTraceCategoryState(asyncHooksEnabled) {
420420

421421
const{ arch, platform, version }=process;
422422

423+
letrefSymbol;
423424
functionref(maybeRefable){
424-
constfn=maybeRefable?.[SymbolFor('nodejs.ref')]||maybeRefable?.[SymbolFor('node:ref')]||maybeRefable?.ref;
425+
if(maybeRefable==null)return;
426+
constfn=maybeRefable[refSymbol??=SymbolFor('nodejs.ref')]||maybeRefable.ref;
425427
if(typeoffn==='function')FunctionPrototypeCall(fn,maybeRefable);
426428
}
427429

430+
letunrefSymbol;
428431
functionunref(maybeRefable){
429-
constfn=maybeRefable?.[SymbolFor('nodejs.unref')]||
430-
maybeRefable?.[SymbolFor('node:unref')]||
431-
maybeRefable?.unref;
432+
if(maybeRefable==null)return;
433+
constfn=maybeRefable[unrefSymbol??=SymbolFor('nodejs.unref')]||maybeRefable.unref;
432434
if(typeoffn==='function')FunctionPrototypeCall(fn,maybeRefable);
433435
}
434436

‎test/parallel/test-process-ref-unref.js‎

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,37 +33,20 @@ class Foo2 {
3333
}
3434
}
3535

36-
// TODO(aduh95): remove support for undocumented symbol
37-
classFoo3{
38-
refCalled=0;
39-
unrefCalled=0;
40-
[Symbol.for('node:ref')](){
41-
this.refCalled++;
42-
}
43-
[Symbol.for('node:unref')](){
44-
this.unrefCalled++;
45-
}
46-
}
47-
4836
describe('process.ref/unref work as expected',()=>{
4937
it('refs...',()=>{
5038
// Objects that implement the new Symbol-based API
5139
// just work.
5240
constfoo1=newFoo();
5341
constfoo2=newFoo2();
54-
constfoo3=newFoo3();
5542
process.ref(foo1);
5643
process.unref(foo1);
5744
process.ref(foo2);
5845
process.unref(foo2);
59-
process.ref(foo3);
60-
process.unref(foo3);
6146
strictEqual(foo1.refCalled,1);
6247
strictEqual(foo1.unrefCalled,1);
6348
strictEqual(foo2.refCalled,1);
6449
strictEqual(foo2.unrefCalled,1);
65-
strictEqual(foo3.refCalled,1);
66-
strictEqual(foo3.unrefCalled,1);
6750

6851
// Objects that implement the legacy API also just work.
6952
consti=setInterval(()=>{},1000);

0 commit comments

Comments
 (0)