You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Duplicate "Setting artifact for function" logs (possible redundant calls to setArtifactPath?)
Description
I guess this might be a minor bug but I did spend a fair chunk of time debugging it so I think it is worth raising. If the issue is valid I'll be happy to raise a PR to get a fix in.
What went wrong?
Every time I package or deploy with the --verbose switch I get duplicate "Setting artifact for function" messages.
For example with individual packaging enabled and a function called "myFunction"
yarn sls package --stage sandbox --verbose
...
[Webpack] Copying existing artifacts
Setting artifact for function 'myFunction' to '.serverless/myFunction.zip'
Setting artifact for function 'myFunction2' to '.serverless/myFunction2.zip'
Setting artifact for function 'myFunction' to '.serverless/myFunction.zip'
Setting artifact for function 'myFunction2' to '.serverless/myFunction2.zip'
...
If I understand correctlty, I think the following patch might do the trick, without introducing any side effects. It is very rough, and I haven't tested it. If you think my analysis is correct I'll go over it again and make sure tests pass etc.
Duplicate "Setting artifact for function" logs (possible redundant calls to
setArtifactPath
?)Description
I guess this might be a minor bug but I did spend a fair chunk of time debugging it so I think it is worth raising. If the issue is valid I'll be happy to raise a PR to get a fix in.
What went wrong?
Every time I package or deploy with the
--verbose
switch I get duplicate "Setting artifact for function" messages.For example with individual packaging enabled and a function called "myFunction"
What did you expect should have happened?
Not to have duplicate logs for each function
What was the config you used?
What stacktrace or error message from your provider did you see?
No explicit stack trace or error message
Suggested Fix
I could be wrong but it looks like there might be some duplicate code in
lib/packageModules.js
First there is a loop to call
setArtifactPath
for each function.serverless-webpack/lib/packageModules.js
Line 236 in 76988d5
it already has logic to set the correct artefact path depending on whether individual packaging is enabled or not
serverless-webpack/lib/packageModules.js
Line 239 in 76988d5
Then further down, if individual packaging is enabled,
setArtifactPath
is called again with the same args which I think is redundantserverless-webpack/lib/packageModules.js
Line 247 in 76988d5
If I understand correctlty, I think the following patch might do the trick, without introducing any side effects. It is very rough, and I haven't tested it. If you think my analysis is correct I'll go over it again and make sure tests pass etc.
See what you think:
Additional Data
5.7.1
5.73.0
Framework Core: 3.7.1 (local)
Plugin: 6.1.5
SDK: 4.3.2
MacOS Monterey 12.6
Also
Thanks for the great plugin!
The text was updated successfully, but these errors were encountered: