Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle rename of net.Server.prototype._listen2 #103

Merged
merged 1 commit into from
Dec 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,17 @@ if (v7plus && !net._normalizeArgs) {
};
}

wrap(net.Server.prototype, '_listen2', function (original) {
// In https://github.com/nodejs/node/pull/11796 `_listen2` was renamed
// `_setUpListenHandle`. It's still aliased as `_listen2`, and currently the
// Node internals still call the alias - but who knows for how long. So better
// make sure we use the new name instead if available.
if ('_setUpListenHandle' in net.Server.prototype) {
wrap(net.Server.prototype, '_setUpListenHandle', wrapSetUpListenHandle);
} else {
wrap(net.Server.prototype, '_listen2', wrapSetUpListenHandle);
}

function wrapSetUpListenHandle(original) {
return function () {
this.on('connection', function (socket) {
if (socket._handle) {
Expand All @@ -90,7 +100,7 @@ wrap(net.Server.prototype, '_listen2', function (original) {
}
}
};
});
}

function patchOnRead(ctx) {
if (ctx && ctx._handle) {
Expand Down