Skip to content

fix(functions): migrate imagemagick sample to sharp and improve test stability#4288

Open
angelcaamal wants to merge 3 commits intoGoogleCloudPlatform:mainfrom
angelcaamal:fix/functions-imagemagick-sharp
Open

fix(functions): migrate imagemagick sample to sharp and improve test stability#4288
angelcaamal wants to merge 3 commits intoGoogleCloudPlatform:mainfrom
angelcaamal:fix/functions-imagemagick-sharp

Conversation

@angelcaamal
Copy link
Copy Markdown
Contributor

@angelcaamal angelcaamal commented Apr 16, 2026

Description

Fixes Internal: b/503436089

Note: Before submitting a pull request, please open an issue for discussion if you are not associated with Google.

Checklist

  • I have followed guidelines from CONTRIBUTING.MD and Samples Style Guide
  • Tests pass: npm test (see Testing)
  • Lint pass: npm run lint (see Style)
  • Required CI tests pass (see CI testing)
  • These samples need a new API enabled in testing projects to pass (let us know which ones)
  • These samples need a new/updated env vars in testing projects set to pass (let us know which ones)
  • This pull request is from a branch created directly off of GoogleCloudPlatform/nodejs-docs-samples. Not a fork.
  • This sample adds a new sample directory, and I updated the CODEOWNERS file with the codeowners for this sample
  • This sample adds a new sample directory, and I created GitHub Actions workflow for this sample
  • This sample adds a new Product API, and I updated the Blunderbuss issue/PR auto-assigner with the codeowners for this sample
  • Please merge this PR for me once it is approved

Note: Any check with (dev), (experimental), or (legacy) can be ignored and should not block your PR from merging (see CI testing).

…stability

- Replaced 'gm' with 'sharp' for image blurring to fix EPIPE errors.
- Fixed temporary file deletion to prevent memory leaks in the blurring function.
- Refactored the test suite to use try...finally, ensuring the Functions Framework process is always killed to release ports (fixes EADDRINUSE).
- Improved test error logging for easier debugging.
@angelcaamal angelcaamal added the api: cloudfunctions Issues related to the Cloud Run functions API. label Apr 16, 2026
@angelcaamal angelcaamal requested review from a team as code owners April 16, 2026 21:24
@angelcaamal angelcaamal added the samples Issues that are directly related to samples. label Apr 16, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the image blurring function from ImageMagick (using the gm library) to the sharp library. The changes include updating the dependencies in package.json, refactoring the core logic in index.js to handle temporary files with sharp, and enhancing the test suite with better error handling. The review feedback correctly identifies that the engines field in package.json must be updated to support sharp's Node.js requirements. Additionally, there are several recommendations to improve code quality by removing dead code (commented-out lines), fixing inconsistent language in comments, and ensuring consistent async/await usage during file cleanup.

Comment thread functions/imagemagick/package.json
Comment thread functions/imagemagick/index.js Outdated
Comment thread functions/imagemagick/index.js Outdated
Comment thread functions/imagemagick/test/index.test.js Outdated
Comment thread functions/imagemagick/test/index.test.js Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: cloudfunctions Issues related to the Cloud Run functions API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant