Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

fix: handle symlinks when creating directory #1640

Merged
merged 3 commits into from
Nov 2, 2023

Conversation

eduardoboucas
Copy link
Member

Summary

When creating a bundle into a directory, we need to respect symlinks and not just copy them as files.

Fixes netlify/cli#6106

@eduardoboucas eduardoboucas requested a review from a team as a code owner November 1, 2023 11:01
Copy link
Contributor

github-actions bot commented Nov 1, 2023

⏱ Benchmark results

Comparing with afaa4ef

largeDepsEsbuild: 2.6s

⬇️ 5.19% decrease vs. afaa4ef

^                   3.3s                                            3.4s                                  
│                   ┌──┐    3.3s            3.2s            3.1s    ┌──┐                                  
│   3.1s            |  |    ┌──┐            ┌──┐            ┌──┐    |  |            3.1s                  
│ ──┌──┐────────────┼──┼────┼──┼────────────┼──┼────────────┼──┼────┼──┼────────────┌──┐──────────────────
│   |  |    2.7s    |  |    |  |    2.7s    |  |            |  |    |  |            |  |    2.7s          
│   |  |    ┌──┐    |  |    |  |    ┌──┐    |  |    2.5s    |  |    |  |    2.6s    |  |    ┌──┐    2.6s  
│   |  |    |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    |  |    ┌──┐    |  |    |  |    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

largeDepsNft: 7.6s

⬇️ 11.84% decrease vs. afaa4ef

^                  11.2s                                                                                  
│  10.5s            ┌──┐                                           10.7s                                  
│   ┌──┐            |  |   10.1s            10s             9.8s    ┌──┐                                  
│   |  |            |  |    ┌──┐            ┌──┐            ┌──┐    |  |            9.5s                  
│ ──┼──┼────────────┼──┼────┼──┼────────────┼──┼────────────┼──┼────┼──┼────────────┌──┐──────────────────
│   |  |    8.3s    |  |    |  |    8.4s    |  |            |  |    |  |            |  |    8.5s          
│   |  |    ┌──┐    |  |    |  |    ┌──┐    |  |    7.6s    |  |    |  |    8.1s    |  |    ┌──┐    7.6s  
│   |  |    |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    |  |    ┌──┐    |  |    |  |    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

largeDepsZisi: 15.3s

⬇️ 6.28% decrease vs. afaa4ef

^  20.6s           20.9s                                           21.1s                                  
│   ┌──┐            ┌──┐   19.9s           19.7s           20.1s    ┌──┐                                  
│   |  |            |  |    ┌──┐            ┌──┐            ┌──┐    |  |           19.4s                  
│   |  |            |  |    |  |            |  |            |  |    |  |            ┌──┐                  
│ ──┼──┼────────────┼──┼────┼──┼───16.5s────┼──┼────────────┼──┼────┼──┼────────────┼──┼──────────────────
│   |  |   16.3s    |  |    |  |    ┌──┐    |  |            |  |    |  |   16.1s    |  |   16.2s   15.3s  
│   |  |    ┌──┐    |  |    |  |    |  |    |  |   15.1s    |  |    |  |    ┌──┐    |  |    ┌──┐    ┌──┐  
│   |  |    |  |    |  |    |  |    |  |    |  |    ┌──┐    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
│   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |▒▒|  
└───┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴────┴──┴──>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend

// `symlinks` map, which we'll later use to create the symlinks in the
// target directory. We can't do that right now because the target path
// may not have been copied over yet.
if (stat.isSymbolicLink()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

We should probably do the same in createZipArchive, but starting with createDirectory for now.

@ascorbic what happened when you tried to deploy the function to production?

Copy link
Member Author

Choose a reason for hiding this comment

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

According to the test, it works: 07061e0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it worked fine in builds

@eduardoboucas eduardoboucas merged commit 390820e into main Nov 2, 2023
@eduardoboucas eduardoboucas deleted the feat/createdirectory-symlink branch November 2, 2023 08:59
Skn0tt pushed a commit to netlify/build that referenced this pull request May 21, 2024
…-it#1640)

* fix: handle symlinks when creating directory

* chore: add test

* chore: skip test on Windows
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ESM dependencies in v2 functions in pnpm repo cause crash in dev
3 participants