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

refactor src/node.js into internal files #5103

Merged
merged 3 commits into from
Mar 22, 2016

Conversation

Fishrock123
Copy link
Contributor

Ok so, this is definitely a bit nuts. Just a bit. Well, the second commit that is.

I figure what this costs us in the short term will be made up for by ease of contribution in the future.

  • commit 1: moves promise setup, stdio, and nextTick out of node.js
  • commit 2: move src/node.js to lib/internal/node.js

This PR is mostly about the first set of changes. Although I'd also like to do the second. src/node.js is very big and it's fairly hard to figure out what you all might need to change for any specific patch.

CI: https://ci.nodejs.org/job/node-test-pull-request/1562/
R=@nodejs/ctc

@Fishrock123 Fishrock123 added process Issues and PRs related to the process subsystem. lib / src Issues and PRs related to general changes in the lib or src directory. labels Feb 5, 2016
scheduleMicrotasks = sMt;
NativeModule = NM;
return exports
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I dunno how to get around some of this dependancy injection for now... Maybe add these to process and then remove them after boot?

@Fishrock123
Copy link
Contributor Author

(fixed linting)


exports.setup = setupNextTick;

function setupNextTick(NativeModule) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need NativeModule? I think you can just use require at this point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@vkurchatkin We don't want this in the regular module cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

what do you mean? require and NativeModule.require are literally the same thing in built-in modules: https://github.com/nodejs/node/blob/master/src/node.js#L1004

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ooooh good catch

@chrisdickinson
Copy link
Contributor

Very interesting! This should go a long way towards clearing things up. It might be worthwhile to CC folks from NW.js and electron to make sure this is compatible with their projects, but if so I'm generally in favor of this.

@Fishrock123
Copy link
Contributor Author

cc @zcbenz / @rogerwang ^^^

scheduleMicrotasks = sMt;
NativeModule = NM;
return exports;
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(Looks like my previous comment got squashed)

I dunno how to get around some of this dependancy injection for now... Maybe add these to process and then remove them after boot?

@Fishrock123 Fishrock123 force-pushed the cleanup-node.js branch 2 times, most recently from e5888b1 to 65b9481 Compare February 6, 2016 16:34
@rogerwang
Copy link
Member

Thanks for CCing @chrisdickinson @Fishrock123 .

It's fine for NW.js.

@Fishrock123
Copy link
Contributor Author

Rebased on master.

I have work that will be sitting ontop of this since it's easier to tell what needs modification, and as such I'd sorta like to get this merged.

cc @trevnorris

function setupNextTick() {
const promises = require('internal/process/promises');
const emitPendingUnhandledRejections = promises.setup(scheduleMicrotasks);
var nextTickQueue = [];
Copy link
Contributor

Choose a reason for hiding this comment

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

could be made const.

EDIT: nope. sorry.

@trevnorris
Copy link
Contributor

going to add the ctc meeting tag. only b/c it relocates so much code, would like a decisive ok from everyone.

@Fishrock123
Copy link
Contributor Author

sigh I should have added it today. Already CC'd everyone though with almost no response?

@jasnell
Copy link
Member

jasnell commented Feb 11, 2016

Sorry, saw the ctc mention just hadn't had any time to review. Will look
through tomorrow.
On Feb 10, 2016 5:27 PM, "Jeremiah Senkpiel" [email protected]
wrote:

sigh I should have added it today. Already CC'd everyone though with
almost no response?


Reply to this email directly or view it on GitHub
#5103 (comment).

@Fishrock123
Copy link
Contributor Author

And before anyone asks, yes this is totally just moving some code around, that's the point haha. :P

@jasnell jasnell added the semver-major PRs that contain breaking changes and should be released in the next major version. label Feb 11, 2016
@jasnell
Copy link
Member

jasnell commented Feb 11, 2016

At a high level this LGTM if CI is green.
I'm going to go out on a limb and mark this semver-major until we can be certain it doesn't break anything. That may be a bit strong, of course, but given how core this part of the code is it's best to be conservative. The tag can be downgraded if we're sure nothing breaks because of this :-)

@Fishrock123
Copy link
Contributor Author

Could you point to where you think it could be semver-major?

Do addons need the file location? I've already heard from two embedders (nw.js and N|Solid) that this doesn't cause significant issues either.

@jasnell
Copy link
Member

jasnell commented Feb 11, 2016

As I said, I'm just being conservative. It shouldn't break anything but it's worth being cautious.

One impact this will have is changing the stack trace on certain errors, e.g:

bash-3.2$ node ~/tmp/test.js
events.js:154
      throw er; // Unhandled 'error' event
      ^
Error: foo
    at Object.<anonymous> (/Users/james/tmp/test.js:5:17)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)
    at startup (node.js:139:18)
    at node.js:999:3
bash-3.2$ 

While that shouldn't have an impact, I think it's at least worth being cautious.

I've kicked off a CITGM run here: https://ci.nodejs.org/job/thealphanerd-smoker/66/

@Fishrock123
Copy link
Contributor Author

One impact this will have is changing the stack trace on certain errors, e.g:

This is not so terribly uncommon and I definitely do not think we guarantee stacktraces. That's like guaranteeing lib/internal APIs.

See: https://github.com/nodejs/node/commits/master/test/message -- 8830797 modifies the same traces but is scheduled for LTS.

@jasnell
Copy link
Member

jasnell commented Feb 11, 2016

Grrr... CITGM smoke testing is currently broken due to the npm/graceful-fs issue on master.
As I said, the change LGTM I'd just prefer to be very conservative with this part of the code and be extra certain. I'll drop the semver-major but I'm going to add a don't-land-in-v4.x until it's been out in a stable release for a while.

@jasnell jasnell added dont-land-on-v4.x and removed semver-major PRs that contain breaking changes and should be released in the next major version. labels Feb 11, 2016
@jasnell
Copy link
Member

jasnell commented Feb 11, 2016

Also see @rvagg's comment here: #5092 (comment) ... so I'm not alone in my caution on this.

@jasnell
Copy link
Member

jasnell commented Mar 22, 2016

The one failure appears to be unrelated. Land it!

PR-URL: nodejs#5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@Fishrock123 Fishrock123 merged commit ec6af31 into nodejs:master Mar 22, 2016
@Fishrock123
Copy link
Contributor Author

landed, thanks everyone!

@jasnell
Copy link
Member

jasnell commented Mar 23, 2016

@Fishrock123 ... woot!

joshgav added a commit to joshgav/node that referenced this pull request Mar 30, 2016
Clarify comments re invoking bootstrap_node.js.
Fix filename to bootstrap_node.js per nodejs#5103.
Fix tests `node.js` -> `bootstrap_node.js`
Fix comment on why we check the loop again before exiting.
`context-inl.h` -> `env-inl.h`
Fishrock123 added a commit to Fishrock123/node that referenced this pull request Mar 31, 2016
PR-URL: nodejs#5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>

Conflicts:
	node.gyp
	src/node.js
Fishrock123 added a commit to Fishrock123/node that referenced this pull request Mar 31, 2016
PR-URL: nodejs#5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Fishrock123 added a commit to Fishrock123/node that referenced this pull request Mar 31, 2016
PR-URL: nodejs#5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request Mar 31, 2016
PR-URL: #5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request Mar 31, 2016
PR-URL: #5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request Mar 31, 2016
PR-URL: #5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request Mar 31, 2016
PR-URL: #5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request Mar 31, 2016
PR-URL: #5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
evanlucas pushed a commit that referenced this pull request Mar 31, 2016
PR-URL: #5103
Reviewed-By: Trevor Norris <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lib / src Issues and PRs related to general changes in the lib or src directory. process Issues and PRs related to the process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.