Skip to content

Commit ef43fc9

Browse files
committed
net: socket._getpeername
Fixes: #43009 If calling `this._handle.getpeername` returns an error at the first call, its result shouldn't be cached to `this._peername`. Signed-off-by: Daeyeon Jeong [email protected]
1 parent be1ca70 commit ef43fc9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/net.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -736,9 +736,11 @@ Socket.prototype._getpeername = function() {
736736
if (!this._handle || !this._handle.getpeername) {
737737
return this._peername || {};
738738
} else if (!this._peername) {
739-
this._peername = {};
739+
const out = {};
740+
const err = this._handle.getpeername(out);
740741
// FIXME(bnoordhuis) Throw when the return value is not 0?
741-
this._handle.getpeername(this._peername);
742+
if (err) return {};
743+
this._peername = out;
742744
}
743745
return this._peername;
744746
};

0 commit comments

Comments
 (0)