-
Notifications
You must be signed in to change notification settings - Fork 773
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
Revert check for fs.realpath.native (#887) #953
Revert check for fs.realpath.native (#887) #953
Conversation
I can see both sides of the argument here. On one hand, defensive coding is good. On the other hand, monkey-patching core modules is a terrible practice, and if you do it anyway, but then fail to do it correctly, I find it hard to be sympathetic. |
Agreed but sometimes, these monkey patches come from other embedded dependencies (such as the Angular case), which puts users in a difficult situation between the dependency and I'm coming as a contributor of log4js which uses streamroller that uses I'm posting this on behalf of my user @myuniverse8 for his issue log4js-node/log4js-node#1225. He uses There's nothing much I can do for him, except to plead my case to both Angular (angular/angular#45546) and to you, @RyanZim. I believe many out there are affected as well, when they use dependencies that poorly monkey-patches Some, including from
And it can be seen immensely difficult to trace to the underlying culprit, up to 5 levels of dependencies for In addition, the #887 isn't documented in the changelog (should be in 10.0.0). So perhaps we can revert out of goodwill as a defensive practice? It will improve Apart from reverting, we can add in warnings to flag out if The pros outweighs the cons |
Yeah, it was just implicitly assumed in the Node version requirement bump. I do sort of like the idea of a warning flag, but would like to get some input from the other maintainers here. @JPeer264 @manidlou @jprichardson |
@RyanZim Sounds great, I shall start on the works for the warning flags in parallel to expedite while waiting for the inputs. I found some existing codes using
node-fs-extra/lib/copy/copy.js Lines 24 to 28 in e0d298d
node-fs-extra/lib/copy/copy-sync.js Lines 18 to 22 in e0d298d
|
I like the idea about the warning flag as well. |
@JPeer264 What are your thoughts on the warning flag implementation? |
Yes |
For the current issue, the warnings when
I hope this looks good to be merged, together with #954. |
I like the warning stuff so far; however, there's no reason to do a fallback or Node version checking. Our |
Strange, the newly added tests ran successfully when I I am going to set it to draft while I try to fix the mocha tests for the CI issues. It might be due to
That would require The added fallback mitigates cases where Any thoughts? |
I hope I have fixed the CI issues resulting from the added tests. Would need a maintainer's approval to run the workflow to determine if it truly resolves. |
Signed-off-by: Lam Wei Li <peteriman@mail.com>
npm will still warn about incompatible engines on install, even without Fallback is unnecessary; if you actually used |
@RyanZim After some thoughts, you are right. Good call!👍 It follows the consistent principle of Lines 102 to 107 in e0d298d
I shall remove the fallback and amend the warning message. At the very least, now |
Signed-off-by: Lam Wei Li <peteriman@mail.com>
…arning Signed-off-by: Lam Wei Li <peteriman@mail.com>
Signed-off-by: Lam Wei Li <peteriman@mail.com>
Co-authored-by: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; will give others a chance to review before merging.
The following packages have been upgraded: - `@pollyjs/adapter-node-http` - `@pollyjs/core` - `@pollyjs/persister-fs` The new Polly.JS packages ship with TypeScript definition files, so the old `@type/pollyjs__` packages have been removed! Additionally, `fs-extra` has been pinned to semver range `^9.0.0` because there a change was released in `^10.0.0` that caused a regression. See: jprichardson/node-fs-extra#953.
The following packages have been upgraded: - `@pollyjs/adapter-node-http` - `@pollyjs/core` - `@pollyjs/persister-fs` The new Polly.JS packages ship with TypeScript definition files, so the old `@type/pollyjs__` packages have been removed! Additionally, `fs-extra` has been pinned to semver range `^9.0.0` because there a change was released in `^10.0.0` that caused a regression. See: jprichardson/node-fs-extra#953.
#887 causes a few regressions, not because of
fs-extra
, but due to other dependencies who are usingfs-extra
.The general gist is that others' improper monkey-patches of
fs
should not impact the import and initialisation offs-extra
.When
fs.realpath.native
isundefined
caused by the improper handling by other packages, it inevitably affected the import and initialisation offs-extra
as theuniversalify
would not be able to parse this line properly.node-fs-extra/lib/fs/index.js
Line 57 in 7edcb16
It results in
fs-extra
throwing errors on import, even if thefs-extra.realpath.native
API is not being used during runtime.And the stacktrace shows:
(src: https://github.com/RyanZim/universalify/blob/a853a4aedc63c69fcdc62b77643d75b0d162a098/index.js#L15)
While it is up to the responsibility of the underlying packages to fix their root cause of poor monkey-patches to
fs
, it might be wise forfs-extra
to keep the check forfs.realpath.native
during initialisation so thatfs-extra
does not throw errors on import.To name a few:
To summarise from the 3 listed issues above, it does seem like most dependencies did not factor in
fs
third-level functions. From the NodeJS fs API documentation, most are second-level functions (i.e. fs.xxx). But there are 2 exceptions since NodeJS 9.2.0 that are in third-level (i.e. fs.xxx.yyy), which arefs.realpath.native
andfs.realpathSync.native
. So if any the packages did some wrapping around, which usually naively only handles direct members (second-level), the third-level functions breaks and becomesundefined
.Even in Angular (traced from the 3rd issue above, log4js-node/log4js-node#1225), they, too, did not factor in the 2 special functions.
https://github.com/angular/angular/blob/1c11a5715576632a4fb7170202395cf95dfbce09/packages/zone.js/lib/node/fs.ts#L20-L26
I have filed an issue to zone.js/node separately here: angular/angular#45546
For your kind consideration, please.