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 filesystem cache not working when package individually is set #1037
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.
Thanks for contributing!
I tried doing this and my 300 lambdas (8MB each zipped) pumped out >50GB of cache, using unique cache keys for each entry essentially multiplies your tree-shaked node_module
by the number of entries. I never thought people would find this useful.
Despite the caveat, this indeed fix a broken feature.
@j0k3r Would you like to comment on the way it passes in the error class? I remember that you made this change for v3 compat.
@vicary have you tried gzip compression? Without specifying compression method, the default cache would be in |
@hieuunguyeen I believe we are talking about the same thing here, the current implementation in I think the only way it would work as expected is to rewire the array of configs into an entry object. This fix only helps from the 2nd build and on, where each function picks up its own last build cache. |
I didn't. |
Looks ok to me too, but I think we should wait for the PR with modern log from Serverless v3 before merging it. |
@hieuunguyeen sorry for being late, the PR I mentioned got merged today. |
c32ead9
to
a2b95be
Compare
@hieuunguyeen Could you rebase and squash one more time? And we'll be good to go! Thanks 🙏 |
Remove leftover parameter
Could you update your tests as we switched from mocha to jest? |
What did you implement:
Fix a bug that occurs when using webpack cache type "filesystem" when package.individually === true
The error displaying by webpack:
Root cause: Webpack filesystem cache generate cache files to the same cache location, with the same cache name, no matter how many times it runs. When package individually and concurrently, multiple concurrent webpack runs results in overlapping of cache location for each individual functions, overwriting each other's caches.
How did you implement it:
Webpack will create a different cache folder name only if webpackConfig.cache.name is not the same (link)
Each time webpackCompile() is called, it needs a separate config that has a different cache.name
The best way to work this out is when individually caching, set the config that is used to package the function to have the cache.name as the function name, which is preformatted to be
{serviceName}-{stage}-{functionName}
How can we verify it:
Enable cache.type = "filesystem"
Package a service with package.individually = true
Todos:
Is this ready for review?: YES
Is it a breaking change?: NO