Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 lambda logical version id for layers in same stack #8066
Fix lambda logical version id for layers in same stack #8066
Changes from 16 commits
3e6fa90
34b0877
91e3077
f927470
f93b1aa
b4ee79a
3a01dc9
b51b81e
6d412bc
b5cb580
3080dd3
14de011
001f440
8678062
619050c
781aa98
a6ccbac
3ad5651
bccd773
997c0f0
8df8aac
a6ec21d
8b21863
18e6b1f
231cf14
4941a15
62cd779
625aea8
d7704ec
b1571c3
9ee00b4
38c867e
ff09d04
6e0be19
193c516
7ad4818
9e08cf5
c8be293
eee300e
76bf822
a9baf17
6967213
b3cea34
7c3ac73
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Let's not use Bluebird` functions which do not have native counterparts.
We should use
BbPromise.all
insteadThere 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 has been updated now, but I realized that both approaches in their current state will run asynchronously on the same hash object. I'm not sure if there could be a race condition or something if
hash.write(chunk)
calls on the same object collide.A potential fix would be to rewrite
addFileContentsToHash
to return a new string or hash object representing the file. Once all promises finish, the array of strings/hashes could then be combined and added to the versionId hash. What do you think?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.
That's true, it won't be deterministic then. We need to run it sequentially, I believe you can achieve it as:
Note that also
layerZipFilePaths
order needs to also be deterministicThere 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, this should be done now.
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.
Let's use
Object.entries
instead of_.entries
(as in a meantime we've dropped support for Node.js v8)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.
Same here
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.
Let's use native
Promise
, and for consistency let's useresolve
name insteadcb
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.
Why do we need to clone it?
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.
Main reason was I assumed this line https://github.com/pwithams/serverless/blob/c8be293c97dd8550f2a5d02ee8d61e6032da3335/lib/plugins/aws/package/compile/functions/index.js#L513 would delete part of the already created cloudformation template if the reference was returned.
Also, in general it seemed like
cfTemplate
is such an important object that if part of it is being returned then it should be a copy so that anything using the return value doesn't accidentally alter it.However, if the delete doesn't actually affect anything (I think removing the clone only fails one of my tests?) then it can be taken out, especially if lodash usage is being minimized.
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.
In fact, if we're taking it as reference, then indeed we should never attempt to modify it. However implying a practice that whenever we take it, we copy it (just in case), could be noisy and difficult to follow, it's definitely not natural in JS.
It's more natural to purely stay away from modifying such reference objects.
So I'd say, let's not clone and let's ensure we do not modify it in further processing
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.
That makes sense. I think it still has to be modified later in some way as
S3Key
can't be part of the hash otherwise it will change every time. I've now moved the clone out of the function and applied it to the returned result instead - this solves theconfiguration._serverlessLayerName
naming issue below too.Let me know if you have any other ideas how to handle keeping
S3Key
out of the hash without a clone.