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

fs: avoid circular dependency in SyncWriteStream #11986

Closed
wants to merge 1 commit into from

Conversation

evanlucas
Copy link
Contributor

@evanlucas evanlucas commented Mar 22, 2017

Previously, there was a circular dependency on the public fs module in
SyncWriteStream. Moving the implementations of fs.writeSync and
fs.closeSync to internal/fs allows us to avoid that circular dependency.

This is an alternative to #11260.

Fixes #11257 (added by @BridgeAR)

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

fs

@nodejs-github-bot nodejs-github-bot added the fs Issues and PRs related to the fs subsystem / file system. label Mar 22, 2017
@Fishrock123
Copy link
Contributor

@evanlucas
Copy link
Contributor Author

so the first CI run failed on some of the windows boxes. Do they not all have cat?

@bzoz
Copy link
Contributor

bzoz commented Mar 22, 2017

Windows shell does not support using ; to separate commands. The test needs to be rewritten for windows.

@gibfahn
Copy link
Member

gibfahn commented Mar 22, 2017

@bzoz could you use a newline instead of ;?

@bzoz
Copy link
Contributor

bzoz commented Mar 22, 2017

@gibfahn that would not work also. From the first glance it looks like cat is used to read file content. This can be done by node itself.

@gibfahn
Copy link
Member

gibfahn commented Mar 22, 2017

Yeah okay, so @evanlucas looks like the choices are:

  1. Run two separate commands, e.g.
const cmd = `echo "${input}" | ${bin} > ${out} 2>&1`;
const cmd2 = `cat ${out}`;
assert.strictEqual(execSync(cmd).toString(), '');
const result = execSync(cmd2).toString();
  1. use fs.readFileSync() or similar and do the read in node.

I assume there's a reason to do the read not through node?

Also if you could add a brief comment to the top of the test explaining what it tests that would be really helpful. It's not immediately obvious to me what it checks.

const path = require('path');

common.refreshTmpDir();
const filename = path.join(__dirname, '..', 'fixtures', 'baz.js');
Copy link
Member

Choose a reason for hiding this comment

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

common.fixturesDir?

Previously, there was a circular dependency on the public fs module in
SyncWriteStream. Moving the implementations of fs.writeSync and
fs.closeSync to internal/fs allows us to avoid that circular dependency.

Fixes: nodejs#11257
@evanlucas
Copy link
Contributor Author

Ok, updated. PTAL

I assume there's a reason to do the read not through node?

No, there wasn't. This used the same script from the original test case. I switched to just reading the file via node. Thanks for checking me on that :]

I also switched to using common.fixturesDir

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

@evanlucas
Copy link
Contributor Author

ouch, CI didn't seem to like that much on anything but OS X :[. I'll dig more into this.

@jasnell jasnell added the wip Issues and PRs that are still a work in progress. label Mar 24, 2017
@BridgeAR
Copy link
Member

@evanlucas would you mind looking into this again? I think it would be great if we can get this fix in.

@BridgeAR BridgeAR added stalled Issues and PRs that are stalled. and removed wip Issues and PRs that are still a work in progress. labels Sep 12, 2017
@BridgeAR
Copy link
Member

Ping @evanlucas

@evanlucas
Copy link
Contributor Author

I kept running in to trouble getting a test that works across all platforms. I don't really have the time to pick this up right now (I'm about to go on vacation), so if someone else wants to pick up here, fine by me. Otherwise, feel free to close and I'll try to get around to it when I get back. Thanks!

@BridgeAR
Copy link
Member

Ping @nodejs/platform-windows @refack would someone mind to take a look at the windows failures?

@bzoz
Copy link
Contributor

bzoz commented Sep 20, 2017

The command for Windows should have extra quotes

`echo "${input}" | "${bin}" > "${out}" 2>&1`

That said, this test passes on my Node 8.5.0. Is this PR still needed?

@BridgeAR
Copy link
Member

BridgeAR commented Sep 23, 2017

@bzoz I can not reproduce this either anymore but in the original bug report there is a user that reported this for 8.5 as well.

@BridgeAR
Copy link
Member

BridgeAR commented Oct 2, 2017

I am closing this as it seems to be resolved in v8.6 even though it is not clear what really solved it.

@BridgeAR BridgeAR closed this Oct 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system. stalled Issues and PRs that are stalled.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stderr redirection breaks require
8 participants