Avoid deploy function no-op buffering#210
Conversation
There was a problem hiding this comment.
Pull request overview
Optimizes aws deploy function by avoiding unnecessary in-memory ZIP buffering when the remote and local artifacts match, leveraging the existing streaming SHA256 helper to compute the local artifact hash first.
Changes:
- Replace in-memory ZIP hashing (
cryptooverreadFileSyncbuffer) with streaming hash computation vialib/utils/get-hash-for-file-path. - Only
readFile/statthe ZIP artifact when an upload is actually needed (hash differs or deploy is forced). - Update unit tests to stub the new hash helper and switch filesystem stubs to
fs.promises.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lib/plugins/aws/deploy-function.js |
Uses streaming file hashing before deciding whether to read/stat the ZIP for upload. |
test/unit/lib/plugins/aws/deploy-function.test.js |
Adjusts unit tests to stub get-hash-for-file-path and fs.promises I/O paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Optimizes deploy function to avoid buffering the full ZIP artifact when deployment can be skipped by comparing the local artifact hash to the remote Lambda CodeSha256.
Changes:
- Use the streaming
get-hash-for-file-pathhelper to compute the local artifact hash before deciding whether to deploy. - Defer reading the ZIP buffer (and stat’ing it) until after the no-op hash check.
- Update unit tests to assert that matching hashes skip artifact
readFile/stat, while changed/forced deploys still read and upload the sameZipFilepayload.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/plugins/aws/deploy-function.js | Moves artifact hashing ahead of ZIP buffering and only reads/stats the artifact when a deploy is required (or forced). |
| test/unit/lib/plugins/aws/deploy-function.test.js | Reworks stubs/assertions to validate the new “skip buffering on no-op” behavior using get-hash-for-file-path and async fs APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR optimizes aws deploy function no-op detection by computing the local artifact hash via the existing streaming hash helper before reading the ZIP into memory, so unchanged functions can skip buffering the full artifact.
Changes:
- Replace in-memory SHA256 hashing (
fs.readFileSync+crypto) withget-hash-for-file-pathstreaming hash for no-op detection. - Move ZIP buffering (
fs.promises.readFile) to only happen when a deployment will proceed (hash mismatch or--force). - Update unit tests to assert that matching hashes skip artifact
readFile/stat, while deploy paths still read and upload the ZIP buffer.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
lib/plugins/aws/deploy-function.js |
Performs streaming hash comparison before reading the ZIP buffer; uses buffered data length for upload size display. |
test/unit/lib/plugins/aws/deploy-function.test.js |
Updates stubbing/assertions to validate that no-op deploys don’t read/stat artifacts and deploys still upload the same ZipFile buffer. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Computes the
deploy functionartifact hash with the streaming hash helper before reading the ZIP buffer.Previously
deploy functionalways loaded the full ZIP withfs.readFileSync()before comparing the local hash with the remote LambdaCodeSha256. That meant even unchanged functions had to buffer the whole artifact just to decide that deployment could be skipped.This keeps the required
ZipFilebuffer for actualupdateFunctionCodecalls, but moves it after the no-op hash check. Unchanged functions now stream the hash and return without reading or statting the artifact.The tests now assert that matching hashes skip
readFileandstat, while changed or forced deployments still read the artifact and pass the sameZipFilepayload to Lambda.