fix!: resolve memory leaks in receiveMessage and response body handling#8
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses connection/body handling leaks by reusing receiveMessage clients, draining non-JSON response bodies, and aligning project/runtime/tooling with Node 22/24.
Changes:
- Cache
receiveMessageHTTP clients and destroy them inMiniSQSClient.destroy() - Drain response bodies for non-JSON responses to avoid socket leaks
- Drop Node 20 support and update dependencies/CI/docs accordingly
Reviewed changes
Copilot reviewed 6 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/index.ts |
Adds a cached undici Client for receiveMessage, drains bodies on non-JSON responses, and destroys cached clients on destroy() |
test/index.ts |
Adds a test intended to cover cached receiveMessage client behavior |
package.json |
Updates Node engine range and bumps @fgiova/aws-signature + undici versions |
README.md |
Updates badges, Node requirements, and usage/API signature examples |
.nvmrc |
Updates default Node version to 22 |
.gitignore |
Ignores /.claude/ |
.github/workflows/node.js.yml |
Updates CI matrix to Node 22/24 and adjusts permissions/coverage/release steps |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| release: | ||
| runs-on: ubuntu-latest | ||
| needs: [test, build] | ||
| if: github.event_name == 'push' # Release only on Push | ||
| permissions: | ||
| contents: write # to be able to publish a GitHub release | ||
| issues: write # to be able to comment on released issues | ||
| pull-requests: write # to be able to comment on released pull requests | ||
| id-token: write # to enable use of OIDC for trusted publishing and npm provenance |
There was a problem hiding this comment.
The release job no longer has the push-only guard (previously if: github.event_name == 'push'). Since this workflow also runs on pull_request, the release job can execute on PR events, which is risky for publishing. Reintroduce an if: condition (e.g., github.event_name == 'push' and/or github.ref == 'refs/heads/main') to ensure releases only run on intended events/branches.
25f8f07 to
3588d5f
Compare
- Cache receiveMessage clients instead of creating/closing one per call, preventing connection churn and potential leaks - Dump response body on non-JSON responses to avoid undrained socket leaks - Destroy cached receiveMessage clients in destroy() method - Drop Node.js 20 support, require ^22.14.0 || >= 24.10.0 - Upgrade @fgiova/aws-signature to ^4.0.0, undici to ^7.21.0 - Update CI matrix and release workflow (Node 22/24 only, OIDC permissions) - Fix README badges, usage example and API signatures BREAKING-CHANGE: Drop support to Node.js 20.x
3588d5f to
ad3cbe3
Compare
BREAKING-CHANGE: Drop support to Node.js 20.x