GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: regression for `fs` module monkey-patching by thefourtheye · Pull Request #2026 · nodejs/node

Conversation

@thefourtheye

@thefourtheye thefourtheye commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

The #2025 breaks graceful-fs module. To catch the accidental breaking like this, this PR introduces a test to make sure that the native fs module is monkey-patchable.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@mscdex mscdex added fs Issues and PRs related to file-system APIs and the fs module. test Issues and PRs related to Node.js core tests and test infrastructure. labels Jun 21, 2015
@Fishrock123

Fishrock123 commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

I am really not sure we should add this terrible hack as a test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thefourtheye

thefourtheye commented Jun 21, 2015

Copy link
Copy Markdown
Contributor Author

@Fishrock123 I think we can avoid surprises like #1898, if we have this test, no?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brendanashworth

brendanashworth commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

It really is horrible, but we've already decided to support graceful-fs's horrible way of hacking core 😞, so +1 on adding the test.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

Not that it's and better, but pretty sure the same functionality can be achieved from the process bindings.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR

ChALkeR commented Jun 21, 2015

Copy link
Copy Markdown
Member

I would recommend against merging this testcase. At least not until #1941 is closed.

The whole situation around graceful-fs is just wrong, there should be a legit (supported in core) way of doing what graceful-fs does, without hacks.

Monkey-patching core and natives-based magic should not be treated as supported, it will never be: it's not possible to support monkey-patching without freezing everything, and supporting the natives magic that graceful-fs currently uses would require to throw out internal/* completely. Supporting that just for fs module is inconsistent.

Once this is declared as supported (which one could assume it would be after merging a dedicated testcase) it would be harder to get this out and solved properly.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

Agreed. Any short term gain here would be a long term maintenance loss. If this is a feature we should/want to support then let's create a proper API for it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@thefourtheye
test: regression for fs module monkey-patching
f9a0686
Testing to make sure that the native `fs` module is monkey-patchable,
as few major libraries like `graceful-fs` rely on this behaviour.
@vkurchatkin

vkurchatkin commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

This is a temporary thing. We don't want to continue breaking graceful-fs again and again. It doesn't mean that this hack is actually supported.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Jun 21, 2015

Copy link
Copy Markdown
Member

we've already decided to support graceful-fs's horrible way of hacking core

We did? What memo did I miss?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

we've already decided to support graceful-fs's horrible way of hacking core

We did? What memo did I miss?

I wouldn't use the word support for this.. I can't imagine we would officially support that.

It's more like "ok people use it so we'll delay breaking it".

(That being said I'm still wondering if we couldn't inline internal modules into code returned by process.binding)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

At what point will the line be drawn to not care that a module has blatantly abused the internal API? It'll get tiresome if every popular module can require us to roll back a change to unsupported API.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

 At what point will the line be drawn to not care that a module has blatantly abused the internal API? It'll get tiresome if every popular module can require us to roll back a change to unsupported API.

I'm not sure, maybe this is a case study in that?

This is blatant abuse, but:

  1. Functionality cannot be achieved without hacks properly in core with core
  2. Broad use because functionality is useful

I think #2 is pretty important also. If this sort of thing is used by less than some amount of people, we should just suggest an older version until #1 is fixed.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

Those are legitimate points, and for these cases we should propose an officially supported API and write tests for that. My main concern going down this "temporary" path is that afterwards it's likely to just be forgotten. Further solidifying the use of the internal API. There's at least one case in core where this has happened.

As long as an alternative and supported API is added, I don't see the need for a depreciation cycle. Even if it's used, it's still internal API. Anyone who uses it knows what that means. At least they'll have a way to update their code.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkurchatkin

vkurchatkin commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

Once again, this is a temporary thing to avoid breakage. Imagine the following workflow:

  • someone includes require('internal/') in fs;
  • runs tests;
  • sees this test failing;
  • reads comments, Github issues, etc;
  • removes require('internal/');

Once graceful-fs is fixed it would be clear that this test is not relevant anymore and should be deleted.

At what point will the line be drawn to not care that a module has blatantly abused the internal API?

Apparently, never, as it "displays a lack of empathy that is incompetence bordering on malice" according to @isaacs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@isaacs

isaacs commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

If we are going to make this a viable platform for real world users, then that means not breaking large swaths of user code, whether they're "blatantly abusing internal APIs" or not. What is exposed is external, regardless of what the docs say.

If you want this to be a project for experimentation and making a pretty thing for engineers to adore, then fine, but let's have the TSC formally state that that's the purpose of io.js and it's not intended for production or stability.

"Empathy" isn't about being a nice person. It's about acknowledging the reality of your users' experience. A platform without stability isn't a good platform that people will use, and software without users is a waste.

Give me a better way to build graceful-fs, and I'll gladly take advantage of it. Until then, literally 100% of your users depend on npm continuing to work properly, and ignoring that fact is a failure of platform engineering.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@isaacs

isaacs commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

And yes, it is tiresome. Welcome to the challenges of maintaining a mature open source software platform! The only alternative is obscurity.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Jun 21, 2015

Copy link
Copy Markdown
Member

Functionality cannot be achieved properly

I've seen this mentioned a few times but without explanations why. What's so special about the core fs module that graceful-fs can't shim it without eval hacks?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

What is exposed is external, regardless of what the docs say.

You know that's a non-applicable argument. JS doesn't have the concept of private members. Even if it's hidden behind a Symbol, it's still possible to retrieve and override. So we depend on conventions. Which you have no trouble violating.

If you want this to be a project for experimentation and making a pretty thing for engineers to adore, then fine, but let's have the TSC formally state that that's the purpose of io.js and it's not intended for production or stability.

Comments such as this are not applicable to the discussion and are borderline harassment. Leave them out.

Give me a better way to build graceful-fs, and I'll gladly take advantage of it.

This is exactly as I suggested. Though it seems you are too preoccupied proving a point than having a discussion.

Show me a ticket that requested this functionality be exposed and I will be sympathetic. Otherwise I have no concern for the developer who lazily uses clearly internal methods and expects them to not break in the future.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@vkurchatkin

vkurchatkin commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

In this case it's not actually about private APIs. The only private API used is process.binding and the code can be easily rewritten without it:

var pre = '(function (exports, require, module, __filename, __dirname) { ';
var post = '});';
var src = pre + require('child_process').execSync('curl https://raw.githubusercontent.com/nodejs/io.js/' + process.version + '/lib/fs.js', { encoding: 'utf8' }) + post;
var vm = require('vm');
var fn = vm.runInThisContext(src);
fn(exports, require, module, __filename, __dirname);

Does exactly the same without any private APIs! But this is just crazy. And actual implementation is not much better.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123

Fishrock123 commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

Those are legitimate points, and for these cases we should propose an officially supported API and write tests for that. My main concern going down this "temporary" path is that afterwards it's likely to just be forgotten. Further solidifying the use of the internal API. There's at least one case in core where this has happened.

As long as an alternative and supported API is added, I don't see the need for a depreciation cycle. Even if it's used, it's still internal API. Anyone who uses it knows what that means. At least they'll have a way to update their code.

Agreed, we'd re-implement private modules into fs as soon as this hits. (Might mean floating a patch for deps/npm/(..)/graceful-fs until the updates bubble up.)

"Empathy" isn't about being a nice person. It's about acknowledging the reality of your users' experience. A platform without stability isn't a good platform that people will use, and software without users is a waste.

Give me a better way to build graceful-fs, and I'll gladly take advantage of it. Until then, literally 100% of your users depend on npm continuing to work properly, and ignoring that fact is a failure of platform engineering.

Dropping the top bit, that is what we are attempting to do. Could we please stop firing shots about this?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR

ChALkeR commented Jun 21, 2015

Copy link
Copy Markdown
Member

@vkurchatkin I hope that code is a joke =).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

@ChALkeR Not really: https://github.com/isaacs/node-graceful-fs/blob/master/fs.js

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR

ChALkeR commented Jun 21, 2015

Copy link
Copy Markdown
Member

@trevnorris I saw that. That is bad, but the curl thing above is far worse =).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR

ChALkeR commented Jun 21, 2015

Copy link
Copy Markdown
Member

I want to link this here, it's loosely related: npm/npm#8619 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@isaacs

isaacs commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

I've seen this mentioned a few times but without explanations why. What's so special about the core fs module that graceful-fs can't shim it without eval hacks?

Try it, and you'll see. File descriptors have to be tracked in a variety of places, and so this means re-implementing fs.ReadStream, fs.readdir, et al, in their entirety. Discussed in more detail in #1941, so I'd rather not rehash it here. See also the entire commit history of https://github.com/isaacs/node-graceful-fs. There have been ample explanations, and I'm not willing to repeat them all on demand.

Since this is functionality that people currently rely on ("correctly" or "lazily" or not), and you want to shift around internals to make the current approach unworkable, either figure out a way to deliver this functionality that allows you to make whatever internal changes you like, without breaking existing userland code. Or decide that user success isn't as important to this project as correctness.

Dropping the top bit, that is what we are attempting to do. Could we please stop firing shots about this?

@Fishrock123 Not everyone is attempting to do that. Thanks for the support, though.

I'm feeling rather exhausted continually trying to make the case for stability. Until there's a clearly defined set of priorities for this project, I'm not comfortable continuing to engage. It's stressful and unproductive.

Send me a PR to make graceful-fs work on io.js, and I'll probably accept it. Or don't.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Jun 21, 2015

Copy link
Copy Markdown
Member

File descriptors have to be tracked in a variety of places, and so this means re-implementing fs.ReadStream, fs.readdir, et al, in their entirety. Discussed in more detail in #1941, so I'd rather not rehash it here. [...]

I've read #1941 but I didn't really see where it makes the case for the current graceful-fs implementation, except that any other approach is a lot of work?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Jun 21, 2015

Copy link
Copy Markdown
Contributor

figure out a way to deliver this functionality that allows you to make whatever internal changes you like

That is completely backwards. We don't need the functionality publicly exposed. You do. So instead of spending so much energy ranting why not open an issue, or probably better a PR, where actual technical discussion can happen.

Or decide that user success isn't as important to this project as correctness.

This type of aggressive rhetoric is unacceptable. Stop with this or leave. It will no longer be tolerated.

I'm feeling rather exhausted continually trying to make the case for stability.

You aren't, but instead fighting for something that has directly affected you. Don't pretend to be a savior for the community. You're belligerent attitude concerning this matter has been in complete contradiction to what you say you're fighting for.

Be like every other developer on this project and create a ticket with a concise explanation of the issue (the one already opened does not meet this criteria) and preferably alternative implementation details that would be helpful.

It is impossible to hide everything in JS. You know that. So we must follow conventions. You broke those conventions and now are expecting us to clean up.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brendanashworth added a commit to brendanashworth/node-graceful-fs that referenced this pull request Jun 21, 2015
@brendanashworth
fix fs module process.binding hackery
1bf13d3
Fix the horrible atrocity introduced in
08471b2. Previously it would evaluate
the code directly through process.binding(), and it now creates a new
Object with the prototype being the real fs module, exported by core.

Ref: nodejs/node#2026
@mikeal

mikeal commented Jun 23, 2015

Copy link
Copy Markdown
Contributor

@trevnorris also, I just realized that this statement in the Stability Policy is from our existing io.js roadmap https://github.com/nodejs/io.js/blob/master/ROADMAP.md#stability-policy which was discussed and ratified all the way back in February https://github.com/nodejs/io.js/blob/master/doc/tc-meetings/2015-02-18.md

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@trevnorris

trevnorris commented Jun 23, 2015

Copy link
Copy Markdown
Contributor

@mikeal I recall the Stability Policy defined in the roadmap. Which largely deals with native and V8 changes.

As for the vote to joining the foundation, I must have been too involved in the TSC Charter document at the time. Also since the link in that issue pointed to a document that states it is still a work in progress, didn't think too much of it. Thanks for pointing me to the additional information.

As for sending a PR, I'd first like to have a short discussion with the TSC (already opened an issue just for the tsc agenda) and get their thoughts on the matter. Partially because I don't know how the other members feel, and because I suck at writing compared to some other devs like yourself and don't want to accidentally convey the wrong message.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mikeal

mikeal commented Jun 23, 2015

Copy link
Copy Markdown
Contributor

As for sending a PR, I'd first like to have a short discussion with the TSC (already opened an issue just for the tsc agenda) and get their thoughts on the matter. Partially because I don't know how the other members feel, and because I suck at writing compared to some other devs like yourself and don't want to accidentally convey the wrong message.

Cool, I guess we'll discuss tomorrow :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rvagg
rvagg force-pushed the master branch from 9d21135 to 628a3ab Compare June 25, 2015 09:18
heavyk added a commit to heavyk/node-graceful-fs that referenced this pull request Jun 25, 2015
@heavyk
integrate amazing-graceful-fs with graceful-fs
3fd8df5
all credit goes to ben
https://github.com/bnoordhuis/amazing-graceful-fs
and nodejs/node#2026

formatting was modified to match
@heavyk heavyk mentioned this pull request Jun 25, 2015
amazing-graceful-fs integration isaacs/node-graceful-fs#45
Merged
@Fishrock123

Fishrock123 commented Jun 28, 2015

Copy link
Copy Markdown
Contributor

@bnoordhuis's re-write has landed in graceful-fs. Closing.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123 Fishrock123 closed this Jun 28, 2015
@SimenB

SimenB commented Jun 28, 2015

Copy link
Copy Markdown
Member

It was reverted, wasn't it?

isaacs/node-graceful-fs#45 (comment)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChALkeR

ChALkeR commented Jun 28, 2015

Copy link
Copy Markdown
Member

@SimenB No, it is merged in graceful-fs 4.x along with a patch that fixes the 0.8 support.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@isaacs

isaacs commented Jun 29, 2015

Copy link
Copy Markdown
Contributor

graceful-fs is now passing tests on latest io.js, and Node >= 0.8

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rvagg

rvagg commented Jun 29, 2015

Copy link
Copy Markdown
Member

sweet, good work @bnoordhuis et. al.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Fishrock123 Fishrock123 mentioned this pull request Jul 1, 2015
Handling EMFILE/ENFILE on fs.open #1941
Closed
@thefourtheye
thefourtheye deleted the fs-monkey-patch-regression branch July 21, 2015 16:23
jbenet added a commit to jbenet/gulp-sourcemaps that referenced this pull request Aug 14, 2015
@jbenet
update graceful-fs dep to 4.x
d87252f
ran into nodejs/node#2026
@jbenet jbenet mentioned this pull request Aug 14, 2015
update graceful-fs dep to 4.x gulp-sourcemaps/gulp-sourcemaps#145
Closed
@bnoordhuis bnoordhuis mentioned this pull request Sep 6, 2015
lib,src: split up big builtin scripts #2714
Closed
This was referenced Feb 5, 2016
upgrade npm to 3.7.1 #5097
Closed
fs: deprecate fs.read's string interface #4525
Closed
@ChALkeR ChALkeR mentioned this pull request Feb 5, 2016
fs: add a temporary fix for re-evaluation support #5102
Closed
ChALkeR added a commit to ChALkeR/io.js that referenced this pull request Feb 11, 2016
@ChALkeR
fs: add a temporary fix for re-evaluation support
3017437
This is needed to give users a grace period before actually breaking
modules that re-evaluate fs sources from context where internal modules
are not allowed, e.g. older version of graceful-fs module.

To be reverted in Node.js 7.0.

Fixes nodejs#5097, see also nodejs#1898, nodejs#2026, and nodejs#4525.
jasnell pushed a commit that referenced this pull request Feb 13, 2016
@ChALkeR @jasnell
fs: add a temporary fix for re-evaluation support
1d79787
This is needed to give users a grace period before actually breaking
modules that re-evaluate fs sources from context where internal modules
are not allowed, e.g. older version of graceful-fs module.

To be reverted in Node.js 7.0

Fixes: #5097, see also #1898, #2026, and #4525.
PR-URL: #5102
Reviewed-By: Rod Vagg <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
stefanmb pushed a commit to stefanmb/node that referenced this pull request Feb 23, 2016
@ChALkeR @stefanmb
fs: add a temporary fix for re-evaluation support
cb0e317
This is needed to give users a grace period before actually breaking
modules that re-evaluate fs sources from context where internal modules
are not allowed, e.g. older version of graceful-fs module.

To be reverted in Node.js 7.0

Fixes: nodejs#5097, see also nodejs#1898, nodejs#2026, and nodejs#4525.
PR-URL: nodejs#5102
Reviewed-By: Rod Vagg <[email protected]>
Reviewed-By: Jeremiah Senkpiel <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
@aliscco aliscco mentioned this pull request Apr 28, 2023
[Snyk] Fix for 5 vulnerabilities aliscco/alisco-node#348
Open
@gr00nd gr00nd mentioned this pull request Feb 6, 2024
[Snyk] Upgrade commander from 2.11.0 to 11.1.0 gr00nd/node#9
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

fs Issues and PRs related to file-system APIs and the fs module. test Issues and PRs related to Node.js core tests and test infrastructure.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

13 participants

@thefourtheye @Fishrock123 @brendanashworth @trevnorris @ChALkeR @vkurchatkin @bnoordhuis @isaacs @mikeal @DavidTPate @SimenB @rvagg @mscdex
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.