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

http: name anonymous functions #9054

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 5 additions & 5 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Agent.defaultMaxSockets = Infinity;
Agent.prototype.createConnection = net.createConnection;

// Get the key for a given set of request options
Agent.prototype.getName = function(options) {
Agent.prototype.getName = function getName(options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Raynos is this good enough or would something like getAgentName be better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally in flamegraphs you see fileName & function name, the two together help a bunch.

In a heapsnapshot you only see function name, however a heap snapshot does show whom holds a reference to the function, if a function is referenced from a class then that anchor point makes it easy to find.

I think having any kind of name at all is great. Having a unique name like Agent_getName does improve it slightly but that might get really annoying for coding style / redundency.

var name = options.host || 'localhost';

name += ':';
Expand All @@ -110,7 +110,7 @@ Agent.prototype.getName = function(options) {
return name;
};

Agent.prototype.addRequest = function(req, options) {
Agent.prototype.addRequest = function addRequest(req, options) {
// Legacy API: addRequest(req, host, port, localAddress)
if (typeof options === 'string') {
options = {
Expand Down Expand Up @@ -173,7 +173,7 @@ Agent.prototype.addRequest = function(req, options) {
}
};

Agent.prototype.createSocket = function(req, options, cb) {
Agent.prototype.createSocket = function createSocket(req, options, cb) {
var self = this;
options = util._extend({}, options);
options = util._extend(options, self.options);
Expand Down Expand Up @@ -236,7 +236,7 @@ Agent.prototype.createSocket = function(req, options, cb) {
}
};

Agent.prototype.removeSocket = function(s, options) {
Agent.prototype.removeSocket = function removeSocket(s, options) {
var name = this.getName(options);
debug('removeSocket', name, 'writable:', s.writable);
var sets = [this.sockets];
Expand Down Expand Up @@ -275,7 +275,7 @@ Agent.prototype.removeSocket = function(s, options) {
}
};

Agent.prototype.destroy = function() {
Agent.prototype.destroy = function destroy() {
var sets = [this.freeSockets, this.sockets];
for (var s = 0; s < sets.length; s++) {
var set = sets[s];
Expand Down