chore(s3-store): replace @shopify/semaphore with async-mutex#829
chore(s3-store): replace @shopify/semaphore with async-mutex#829Emperiusm wants to merge 1 commit into
Conversation
@shopify/semaphore@3.1.0 was archived/deprecated by Shopify and shows
"Package no longer supported" on every npm install. async-mutex provides
the equivalent counting Semaphore primitive with active maintenance,
similar API surface, and zero runtime deps.
API mapping in src/index.ts:
- `Semaphore` from @shopify/semaphore → `Semaphore` from async-mutex
- `permit = await sem.acquire()` (returns Permit, with `.release(): Promise`)
→ `const [, release] = await sem.acquire()` (returns [value, releaseFn])
- `permit.release().catch(() => {})` (Promise) → `release()` (sync, no Promise)
The previous `.catch(() => {})` no-ops were defensive against a Permit
Promise rejection that async-mutex doesn't have — release is a sync
function that throws only on programmer error, so the swallow becomes a
direct call.
- The `permit: Permit | undefined` slot becomes `releasePermit: (() => void) | undefined`
since we no longer hold a Permit object, just its release fn.
Verified: tsc --build is clean for @tus/s3-store; the unit-test subset
(12 tests that don't need real AWS) pass; the 21 S3-integration failures
("Region is missing") are pre-existing and require AWS credentials —
unaffected by this change.
|
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
WalkthroughThe S3 store's multipart upload concurrency control is refactored to replace ChangesSemaphore library replacement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Perhaps we should just copy the class from Can you update? |
Why
@shopify/semaphore@3.1.0was archived by Shopify and surfaces as aPackage no longer supporteddeprecation on everynpm installof@tus/s3-store. There is no successor release planned, and downstream projects taking dependency hygiene seriously (e.g. vianpm audit/ install-log linting) need a path off it.async-mutexis actively maintained (~17M weekly downloads), MIT-licensed, has zero runtime deps, and exposes a countingSemaphorewith an equivalent contract.What
packages/s3-store/src/index.tsis the only consumer. The diff is small:API delta this PR adapts to:
await sem.acquire()returnsPermitawait sem.acquire()returns[value, releaseFn]permit.release(): Promise<void>releaseFn(): void(sync)The previous
permit?.release().catch(() => {})calls were defending against a Promise rejection thatasync-mutex.releasedoes not have (it's a sync fn that only throws on programmer error — over-release of a permit). The.catchno-ops collapse to directrelease()calls.Verified
tsc --buildis clean for@tus/s3-storeafter the change.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
@tus/s3-store's public surface — only the internal concurrency primitive.🤖 Generated with Claude Code