-
Notifications
You must be signed in to change notification settings - Fork 384
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: follow symlinks w/ netlify deploy
#5650
Conversation
fdde8b6
to
3f2ea28
Compare
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.
Leaving some notes for additional context.
@@ -178,31 +178,6 @@ const validateFolders = async ({ deployFolder, functionsFolder }) => { | |||
return { deployFolderStat, functionsFolderStat } | |||
} | |||
|
|||
const getDeployFilesFilter = ({ deployFolder, site }) => { |
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.
Unlike folder-walker
, fast-glob
does not accept a file filter function.
Therefore this function was deleted and its logic was adapted for the fast-glob
file queries that exist in src/utils/deploy/hash-files.mjs
.
@@ -8,17 +8,6 @@ import { EDGE_FUNCTIONS_FOLDER, PUBLIC_URL_PATH } from './consts.mjs' | |||
|
|||
const distPath = getPathInProject([EDGE_FUNCTIONS_FOLDER]) | |||
|
|||
export const deployFileNormalizer = (rootDir, file) => { |
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.
This logic was moved to the normalizePath
function in src/utils/deploy/util.mjs
.
Hi @ajschmidt8! I appreciate the PR. Properly supporting symlinks for |
Looks like there's a linting error. From a first cursory look, it's hard for me to differentiate the changes that fix the issue from refactorings. This makes it really hard for me to think about unwanted side-effects of this change. Would it be possible for you to trim this PR down to the minimal change that fixes the bug? I can also open a PR for that instead. Again, i'm really happy you opened the PR, I'm just thinking that splitting things up into a fix PR and a refactoring PR would make it easier to review for me, and easier to merge with confidence. |
I'll resolve the linting errors and merge conflicts soon.
I started down that route. Unfortunately most of these changes are intertwined. Here's why:
Since both libraries have Unfortunately that's not the case since It seemed wasteful to devise a way to merge/concatenate these two independent I realize there are a lot of changes. I'm happy to elaborate on any of them as needed. I would recommend working backward and starting with reviewing the tests. If the test assertions looks sound, then you can be assured that the functions are working as expected. Ultimately the majority of my changes were only made to During my development and debugging process, it was useful to set up a small demo site with symlinks to test out my changes. I used On each branch, I also added the statements below before the console.log("files:", files)
console.log("filesShaMap:", filesShaMap)
process.exit(0) // exit early to prevent having to wait for a full deploy to occur |
I'm not opposed to you opening a separate PR. But I'd prefer not to spend too much more time on these changes myself (aside from minor PR requests) based on the time it took to get these changes working so far. |
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.
all of the functionality from these functions is replaced by the few lines of code in the mapper
functions in src/utils/deploy/hash-fns.mjs
and src/utils/deploy/hash-files.mjs
Hey @ajschmidt8! Please excuse me for not replying earlier. We've discussed this quite a bit internally, and while we agree that ideally the behaviour around Symlinks in CLI/NF Build should be the same, we are wary of other customers relying on this "buggy" behaviour. So we'd like to take any changes slow, and this might take a while. I'll go ahead and close this PR for now - we will come back to solving this in the future, but we'll drive the implementation so you don't have to do any more work on this. If you rely on this fix, I think you should be able to use your forked version of the CLI, right? |
Appreciate the follow-up. I do hope you guys address this quickly. I'd prefer to abandon my fork ASAP in favor of an upstream fix. Keep me posted if there's anything I can do to help with this effort. |
@Skn0tt the way around this is to provide some type of flag that a user can set to follow a symlink. This is causing me issues right now as well, and for such an old issue has there been no update on providing this support today? |
Summary
Fixes #1809
There's a discrepancy between deploys that happen via Netlify's auto-deploys and the
netlify deploy
CLI command. Auto-deploys follow symlinks while thenetlify deploy
CLI command does not.This PR resolves that discrepancy by ensuring the
netlify deploy
command does follow symlinks.As mentioned by @tinfoil-knight in this comment, the fast-glob library follows symlinks by default.
Therefore, I've replaced the folder-walker dependency that was previously used with
fast-glob
.The APIs and return values of these libraries are different, so I've adjusted the code accordingly.
Further, I've replaced the
streams
implementations insrc/utils/deploy/hash-files.mjs
withasync
/await
promises (and also updatedsrc/utils/deploy/hash-fns.mjs
for consistency).This seemed like the preferred approach based on some of the
TODO
comments insrc/utils/deploy/hasher-segments.mjs
(which has now been deleted).This switch also enabled the removal of the following dependencies:
pump
from2-array
flush-write-stream
parallel-transform
Finally, tests were added/updated according to these changes.
For us to review and ship your PR efficiently, please perform the following steps:
passes our tests.
A picture of a cute animal (not mandatory, but encouraged)