-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix(fslib): ensure path is a string before calling replace(). #4215
Conversation
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.
Any idea why the CI fails? |
Test added. |
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
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.
I'm not sure if this is safe to land so I'll defer to @paul-soporan since he looked into Buffer
support in #1584 and knows more about what is required.
Ref #1818
Any idea why the CI fails?
A flaky test, you can ignore it.
Anything else on this commit to do? |
I apologize for the delay, I'll try doing an in-depth review tomorrow. |
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.
Haven't had time to look into the encoding issues yet, but, regarding the API, toPortablePath
isn't the right place for this change. It's only meant to accept a Path
.
Introducing an invisible layer here means that things might break (Edit: Actually, in this specific case they wouldn't, but still, it gives off the false impression that we fully support Buffer
s without them being implemented in the right layer) when going through the FS
classes that only expect paths.
The right fix would be to create a BufferFS
to automatically wrap the patchedFs
just like the URLFS
does.
In some instances Node path may be a Buffer instead of a string causing a p.replace is not a function error.
I have made the suggested changes and rebased. |
I'm sorry if that wasn't clear - I meant to say that we should create a berry/packages/yarnpkg-fslib/sources/patchFs.ts Lines 146 to 147 in e143651
|
I have closed the pull request. I don't want to see it through. My workaround is just to delete the build directory before running yarn build. |
What's the problem this PR addresses?
Random error when calling
yarn run build
on Windows 11, node 17.6.0, and yarn 3.2.0.Debugging the issue, here is the value of
p
and also the stack trace during the failure.How did you fix it?
path
infs.rmdirSync
and other Node functions can bestring | Buffer | URL
. So call.toString()
before calling.replace()
.Checklist