Skip to content

Avoid deploy function no-op buffering#210

Merged
GrahamCampbell merged 3 commits intomainfrom
fix/deploy-function-hash-before-read
Apr 29, 2026
Merged

Avoid deploy function no-op buffering#210
GrahamCampbell merged 3 commits intomainfrom
fix/deploy-function-hash-before-read

Conversation

@GrahamCampbell
Copy link
Copy Markdown
Contributor

@GrahamCampbell GrahamCampbell commented Apr 29, 2026

Computes the deploy function artifact hash with the streaming hash helper before reading the ZIP buffer.

Previously deploy function always loaded the full ZIP with fs.readFileSync() before comparing the local hash with the remote Lambda CodeSha256. That meant even unchanged functions had to buffer the whole artifact just to decide that deployment could be skipped.

This keeps the required ZipFile buffer for actual updateFunctionCode calls, 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 readFile and stat, while changed or forced deployments still read the artifact and pass the same ZipFile payload to Lambda.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 (crypto over readFileSync buffer) with streaming hash computation via lib/utils/get-hash-for-file-path.
  • Only readFile/stat the 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.

Comment thread lib/plugins/aws/deploy-function.js Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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-path helper 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 same ZipFile payload.

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.

Comment thread lib/plugins/aws/deploy-function.js Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) with get-hash-for-file-path streaming 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.

@GrahamCampbell GrahamCampbell merged commit ac7b5ef into main Apr 29, 2026
8 checks passed
@GrahamCampbell GrahamCampbell deleted the fix/deploy-function-hash-before-read branch April 29, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants