Skip to content

Commit c64f6b1

Browse files
committed
check ref/unref on _handle in net.socket
1 parent 55b9fc4 commit c64f6b1

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

lib/internal/http2/core.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,19 +1122,13 @@ class Http2Session extends EventEmitter {
11221122

11231123
ref() {
11241124
if (this[kSocket]) {
1125-
assert(this[kSocket]._handle);
1126-
if (typeof this[kSocket]._handle.ref === 'function') {
1127-
this[kSocket].ref();
1128-
}
1125+
this[kSocket].ref();
11291126
}
11301127
}
11311128

11321129
unref() {
11331130
if (this[kSocket]) {
1134-
assert(this[kSocket]._handle);
1135-
if (typeof this[kSocket]._handle.unref === 'function') {
1136-
this[kSocket].unref();
1137-
}
1131+
this[kSocket].unref();
11381132
}
11391133
}
11401134
}

lib/net.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,9 @@ Socket.prototype.ref = function() {
11401140
return this;
11411141
}
11421142

1143-
this._handle.ref();
1143+
if (typeof this._handle.ref === 'function') {
1144+
this._handle.ref();
1145+
}
11441146

11451147
return this;
11461148
};
@@ -1152,7 +1154,9 @@ Socket.prototype.unref = function() {
11521154
return this;
11531155
}
11541156

1155-
this._handle.unref();
1157+
if (typeof this._handle.unref === 'function') {
1158+
this._handle.unref();
1159+
}
11561160

11571161
return this;
11581162
};

0 commit comments

Comments
 (0)