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

os: name every function OS module #9250

Closed
wants to merge 1 commit into from

Conversation

lprasanthi
Copy link

@lprasanthi lprasanthi commented Oct 24, 2016

Checklist
  • make -j8 test (UNIX), or vcbuild test nosign (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)

os

Description of change

There are too many anonymous functions in the source code which makes heap debugging frustrating.
Naming functions in os module as part of this issue

@nodejs-github-bot nodejs-github-bot added the os Issues and PRs related to the os subsystem. label Oct 24, 2016
@lprasanthi
Copy link
Author

@thefourtheye

@thefourtheye
Copy link
Contributor

@lprasanthi Can you please change the commit message, as per these guidelines?

There are too many anonymous functions in the source code which makes
the debugging frustrating.

We are fixing this issue by naming every anonymous function in all the
modules.As part of which,this commit contains changes to os module
@lprasanthi lprasanthi changed the title Name every function OS module os: name every function OS module Oct 24, 2016
@thefourtheye
Copy link
Contributor

Copy link
Contributor

@princejwesley princejwesley left a comment

Choose a reason for hiding this comment

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

LGTM

@pvsousalima
Copy link
Contributor

pvsousalima commented Oct 24, 2016

In my pull requests the same type of tests are failing when they go to CI Run: #9225 #9217

Copy link
Member

@imyller imyller left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, but I'm afraid I'm opposed to this as it changes the code for no benefit.

Relevant stack trace line before:

 at Object.exports.arch (os.js:27:9)

..and with this change:

at Object.arch (os.js:27:9)

I'm not seeing the benefit here. Sorry.

If you want to find anonymous functions where naming them will improve the stack trace, look for code like this:

some.functionCall(arg1, arg2, function() {
  //this function needs a name
});

@Trott
Copy link
Member

Trott commented Oct 24, 2016

Actually, I suspect this can be salvaged by creating an object in the module named os (or, at least, OS?) and exporting the object. Change all the exports.arch = function... stuff to os.arch = function... and BOOM instant better stack traces (I think--I haven't, you know, actually tested this theory).

@Fishrock123
Copy link
Contributor

@Trott this is about heap snapshots and such, not stacktraces.

@Trott
Copy link
Member

Trott commented Oct 25, 2016

If I'm not mistaken, the same issue applies to heap snapshots.

os.arch currently appears as exports.arch in heap snapshots like this:
screen shot 2016-10-24 at 7 00 25 pm

With the change here, it will appear as simply arch:
screen shot 2016-10-24 at 7 04 38 pm

My understanding of how to read heap snapshots in Chrome Dev Tools is limited, so I may be missing something. Corrections are welcome. But if I'm not completely off base here, then I would think at least that my suggestion in #9250 (comment) is more the way to go.

@silverwind
Copy link
Contributor

silverwind commented Oct 25, 2016

@Trott any idea on how to remove the Object. prefix? It shows with

mod=exports;
mod.fn = () => console.trace();
fn();

but curiously, not when immediatly invoked:

mod=exports;
(mod.fn = () => console.trace())();

@Trott
Copy link
Member

Trott commented Oct 26, 2016

@silverwind Not sure, actually. Haven't had time to look too closely, but if someone else knows or figures it out, please post here. :-D

@jasnell
Copy link
Member

jasnell commented Mar 24, 2017

Any updates on this?

@jasnell jasnell added the stalled Issues and PRs that are stalled. label Mar 24, 2017
@fhinkel
Copy link
Member

fhinkel commented May 26, 2017

There hasn't been any activity here. I'm closing this. Feel free to reopen (or ping a collaborator) if I closed this in error.

@fhinkel fhinkel closed this May 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
os Issues and PRs related to the os subsystem. stalled Issues and PRs that are stalled.
Projects
None yet
Development

Successfully merging this pull request may close these issues.