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

lib: include cached modules in module.children #14132

Merged
merged 1 commit into from
Jul 24, 2017

Conversation

bnoordhuis
Copy link
Member

@bnoordhuis bnoordhuis commented Jul 8, 2017

module.children is supposed to be the list of modules included by this
module but lib/module.js failed to update the list when the included
module was retrieved from Module._cache.

Fixes: #7131
CI: https://ci.nodejs.org/job/node-test-pull-request/9038/

@nodejs-github-bot nodejs-github-bot added the module Issues and PRs related to the module subsystem. label Jul 8, 2017
@@ -0,0 +1,5 @@
'use strict';
require('sys'); // Builtin should not show up in module.children array.
Copy link
Member Author

Choose a reason for hiding this comment

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

I picked a module that's unlikely to have already been included by test/common.js.

@refack
Copy link
Contributor

refack commented Jul 8, 2017

@Slayer95
Copy link

Slayer95 commented Jul 8, 2017

Does this mean that a structure a -> b -> a will be created if a and b are mutually dependent?

@bnoordhuis
Copy link
Member Author

@Slayer95 Yes, there can be cycles now.

(That's the reason for the changes to test/sequential/test-module-loading.js: it didn't handle them.)

const common = require('../common');
const assert = require('assert');

const dir = common.fixturesDir + '/GH-7131';
Copy link
Member

Choose a reason for hiding this comment

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

path.join()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Mwah, I can change that if you feel strongly but we have a gazillion tests that use simple string concatenation.

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer it. Updating the remaining ones for consistency would be a good Code-and-Learn activity (ping @nodejs/codeandlearn)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure since https://nodejs.org/api/modules.html#modules_all_together (module names are URL like)
Maybe path.posix.join, but I'm +1 on literal /

Copy link
Member

Choose a reason for hiding this comment

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

@refack to be clear, you're saying that path.join() is wrong because it'll resolve to a\\b on Windows, and require always takes a POSIX style path (a/b)?

I'd rather have a concatenation (or `${common.fixturesDir}/GH-7131` ) than path.posix.join

Copy link
Contributor

Choose a reason for hiding this comment

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

@refack to be clear, you're saying that path.join() is wrong because it'll resolve to a\b on Windows, and require always takes a POSIX style path (a/b)?

Not wrong per se, just less right.


const dir = common.fixturesDir + '/GH-7131';
const b = require(dir + '/b');
const a = require(dir + '/a');
Copy link
Member

Choose a reason for hiding this comment

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

path.join()?

@bnoordhuis
Copy link
Member Author

path.join() nits included, new CI: https://ci.nodejs.org/job/node-test-pull-request/9202/

@refack
Copy link
Contributor

refack commented Jul 18, 2017

path.join() nits included, new CI: https://ci.nodejs.org/job/node-test-pull-request/9202/

I have to kill the ARM job https://ci.nodejs.org/job/node-test-binary-arm/9302/ It was Green (yellow) but wasn't reporting that it finished upstream.

@jasnell
Copy link
Member

jasnell commented Jul 18, 2017

CI appears to be having some issues right now

@bnoordhuis
Copy link
Member Author

@refack
Copy link
Contributor

refack commented Jul 18, 2017

CI again: https://ci.nodejs.org/job/node-test-pull-request/9216/

FWIW https://ci.nodejs.org/job/node-test-binary-arm/9302/ was green, except for a flake in freeBSD. And currently CI is even flakier then last night.

@bnoordhuis
Copy link
Member Author

@bnoordhuis
Copy link
Member Author

FWIW https://ci.nodejs.org/job/node-test-binary-arm/9302/ was green, except for a flake in freeBSD. And currently CI is even flakier then last night.

@refack Are you saying that the whole run was green (except for a flake), not just the ARM machines? The node-test-binary-arm in the URL threw me off.

@refack
Copy link
Contributor

refack commented Jul 19, 2017

@refack Are you saying that the whole run was green (except for a flake), not just the ARM machines? The node-test-binary-arm in the URL threw me off.

Yes. Whole run was green.

`module.children` is supposed to be the list of modules included by this
module but lib/module.js failed to update the list when the included
module was retrieved from `Module._cache`.

Fixes: nodejs#7131
PR-URL: nodejs#14132
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
@bnoordhuis bnoordhuis closed this Jul 24, 2017
@bnoordhuis bnoordhuis deleted the fix7131 branch July 24, 2017 15:00
@bnoordhuis bnoordhuis merged commit c83d9bb into nodejs:master Jul 24, 2017
addaleax pushed a commit that referenced this pull request Jul 24, 2017
`module.children` is supposed to be the list of modules included by this
module but lib/module.js failed to update the list when the included
module was retrieved from `Module._cache`.

Fixes: #7131
PR-URL: #14132
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
@addaleax addaleax mentioned this pull request Jul 24, 2017
@addaleax addaleax mentioned this pull request Aug 2, 2017
@MylesBorins
Copy link
Contributor

MylesBorins commented Aug 16, 2017

@bnoordhuis should this be backported to LTS? if so how far back?

edit: considering this broke some stuff in the wild it might be best to just leave it out... at least of v4.x

Slayer95 referenced this pull request in smogon/pokemon-showdown Sep 2, 2017
Matchmaker is now globally accessible under Ladders, rather than
needing to be manually required.

This fixes a crash when hotpatching certain things.
@Slayer95
Copy link

Slayer95 commented Sep 2, 2017

Confirming that this did break stuff at least for our project, which had to be dealt with using a global state-based quick&dirty fix.

@MylesBorins
Copy link
Contributor

@nodejs/tsc
thoughts regarding the breakage mentioned above

@MylesBorins
Copy link
Contributor

ping @nodejs/tsc and @nodejs/lts one more time

@mcollina
Copy link
Member

-1 in backporting

@kumarrishav
Copy link
Contributor

It's breaking this too. because of this . https://github.com/krakenjs/freshy/blob/master/index.js#L85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.