chore(s3-store): replace @shopify/semaphore with async-mutex
Why
@shopify/[email protected] was archived by Shopify and surfaces as a Package no longer supported deprecation on every npm install of @tus/s3-store. There is no successor release planned, and downstream projects taking dependency hygiene seriously (e.g. via npm audit / install-log linting) need a path off it.
async-mutex is actively maintained (~17M weekly downloads), MIT-licensed, has zero runtime deps, and exposes a counting Semaphore with an equivalent contract.
What
packages/s3-store/src/index.ts is the only consumer. The diff is small:
-import {Semaphore, type Permit} from '@shopify/semaphore'
+import {Semaphore} from 'async-mutex'
API delta this PR adapts to:
| @shopify/semaphore | async-mutex |
|---|---|
await sem.acquire() returns Permit |
await sem.acquire() returns [value, releaseFn] |
permit.release(): Promise<void> |
releaseFn(): void (sync) |
The previous permit?.release().catch(() => {}) calls were defending against a Promise rejection that async-mutex.release does not have (it's a sync fn that only throws on programmer error β over-release of a permit). The .catch no-ops collapse to direct release() calls.
Verified
tsc --buildis clean for@tus/s3-storeafter the change.- Local
mocha dist/test/*.js: the 12 tests that don't need real AWS credentials pass; the 21Region is missingintegration failures are pre-existing and unaffected.
Notes
- Found via dependency-deprecation cleanup in a downstream consumer (Second Opinion). Filing both the issue context and the patch since the change is small enough to ship together.
- No semver-major behavior change in
@tus/s3-store's public surface β only the internal concurrency primitive.
π€ Generated with Claude Code
β οΈ No Changeset found
Latest commit: dca353dd7abe461330f8abbb5cf40f9e9e217f90
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
No actionable comments were generated in the recent review. π
βΉοΈ Recent review info
βοΈ Run configuration
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
Run ID: 53fb58bd-8920-4104-ac21-bc720e677224
π₯ Commits
Reviewing files that changed from the base of the PR and between 57b1be9bcb01c035bdc30aa1658db36197a409cb and dca353dd7abe461330f8abbb5cf40f9e9e217f90.
β Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
π Files selected for processing (2)
packages/s3-store/package.jsonpackages/s3-store/src/index.ts
Walkthrough
The S3 store's multipart upload concurrency control is refactored to replace @shopify/semaphore with async-mutex. The dependency is updated, the import is switched, and the uploadParts method is adapted to use the new library's callback-based release API instead of permit objects.
Changes
Semaphore library replacement
| Layer / File(s) | Summary |
|---|---|
Dependency & Import Migration packages/s3-store/package.json, packages/s3-store/src/index.ts |
Dependency declaration replaced with async-mutex and import statement updated to use the new library instead of @shopify/semaphore. |
Semaphore API Implementation packages/s3-store/src/index.ts |
uploadParts method refactored to track and invoke a releasePermit callback instead of storing and calling .release() on a Permit object; cleanup and error handlers adapted to use optional chaining with the release function. |
Estimated code review effort
π― 2 (Simple) | β±οΈ ~10 minutes
Possibly related PRs
- tus/tus-node-server#728: Modifies packages/s3-store multipart upload permit release logic; directly related refactoring of semaphore/concurrency handling.
π₯ Pre-merge checks | β 5
β Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | β Passed | The title accurately summarizes the main change: replacing @shopify/semaphore with async-mutex in the s3-store package. |
| Description check | β Passed | The description provides clear rationale (archived dependency), implementation details, API differences, and verification steps directly related to the changeset. |
| Docstring Coverage | β Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
| Linked Issues check | β Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | β Passed | Check skipped because no linked issues were found for this pull request. |
βοΈ Tip: You can configure your own custom pre-merge checks in the settings.
β¨ Finishing Touches
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
[!WARNING]
Review ran into problems
π₯ Problems
Git: Failed to clone repository. Please run the
@coderabbitai full reviewcommand to re-trigger a full review. If the issue persists, setpath_filtersto include or exclude specific files.
[!TIP]
π¬ Introducing Slack Agent: The best way for teams to turn conversations into code.
Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
- Generate code and open pull requests
- Plan features and break down work
- Investigate incidents and troubleshoot customer tickets together
- Automate recurring tasks and respond to alerts with triggers
- Summarize progress and report instantly
Built for teams:
- Shared memory across your entire orgβno repeating context
- Per-thread sandboxes to safely plan and execute work
- Governance built-inβscoped access, auditability, and budget controls
One agent for your entire SDLC. Right inside Slack.
π Get started
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
| Diff | Package | Supply Chain Security |
Vulnerability | Quality | Maintenance | License |
|---|---|---|---|---|---|---|
| async-mutex@β0.5.0 |
Perhaps we should just copy the class from @shopify/semaphore, it's been working well for us, it's not a moving target the datastructure isn't going to change, and then we own it and reduce dependency problems and security.
Can you update?