Skip to content

@tus/s3-store: keep cached metadata in sync on length declaration and removal - #901

Closed
ferhatelmas wants to merge 1 commit into
tus:mainfrom
ferhatelmas:metadata-sync
Closed

ferhatelmas wants to merge 1 commit into
tus:mainfrom
ferhatelmas:metadata-sync

Conversation

@ferhatelmas

@ferhatelmas ferhatelmas commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

related to #900


Devin Review

… removal

Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
@changeset-bot

changeset-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: c49388f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tus/s3-store Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration

Copy link
Copy Markdown

Could we also invalidate cached metadata in deleteExpired() here? That path bypasses remove(), so awaiting clearCache() there doesn’t cover expiration cleanup. A regression test that warms the cache, expires and deletes an incomplete upload, then verifies getUpload() reports it missing would cover this.

Separately, getUpload() still treats a missing multipart upload as completed when .info survives—for example after an S3 lifecycle abort. That can be a follow-up, but we should address it before #900 starts exempting these uploads from expiration.

Murderlon added a commit to ferhatelmas/tus-node-server that referenced this pull request Nov 2, 2026
… cleanup (tus#910)

## Summary

Closes tus#901, retaining @ferhatelmas’s commit and resolving the test
conflict with current `main`. Updating the contributor branch was denied
(HTTP 403).

- Update cached metadata after deferred-length declaration and await
eviction in `remove()`.
- Evict metadata in `deleteExpired()`, which bypasses `remove()`, so
subsequent lookups do not use stale cached upload information after
server cleanup.
- Define missing-key deletion as successful at the `KvStore` boundary.
`FileKvStore.delete()` uses `fs.rm(..., {force: true})`, preserving
genuine failures without filesystem-specific handling in S3.
- Cover deferred-length uploads with `FileKvStore`, expiration cache
eviction, absent cache entries, and eviction failures. Preserve existing
empty-upload regressions and assert that missing multipart-upload
lookups make no extra HEAD request.

Final-object HEAD verification is deliberately excluded to avoid adding
a sequential S3 request to every completed-upload lookup. The existing
limitation remains: externally aborted uploads with surviving metadata
can be reported as completed; tus#900 would also exempt these from
expiration. This trade-off was accepted for short resume windows
relative to multi-day lifecycle cleanup. Server HEAD/PATCH behavior and
cleanup locking are unchanged here.

Includes patch changesets for `@tus/s3-store` and `@tus/utils`. Existing
Changesets `updateInternalDependencies: patch` configuration updates
dependency ranges during the release version step.

Verified locally: `npm run build`, `npm run format:check`, and `npm run
lint`. Tests run in CI per repository instructions.

Link to Devin session:
https://app.devin.ai/sessions/13d351b16409431d8791d4164d8692e5
Open in Devin Desktop:
https://app.devin.ai/desktop/session/13d351b16409431d8791d4164d8692e5?variant=devin
Requested by: @Murderlon
<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/tus/tus-node-server/pull/910"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->

---------

Signed-off-by: Ferhat Elmas <elmas.ferhat@gmail.com>
Co-authored-by: Ferhat Elmas <elmas.ferhat@gmail.com>

This branch had an error being deployed

1 failed deployment
external-testing — c49388fd Deployed Oct 26, 2026 by ferhatelmas via Tests #119
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.

1 participant