ankitpokhrel / ankitpokhrel/tus-php

Deleting the cache entry inside the upload.complete event makes the completing request itself return 410

Open
#468 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
1.5k
Forks
220
PR merge metrics
No merged PRs in 30d

Description

**Version:** v2.4.0

## Summary

If a host application deletes the upload's cache entry from inside the `tus-server.upload.complete` event handler (a natural pattern for "consume the upload on completion" flows), the server's own post-event re-read of that entry causes the very request that just succeeded to respond **410 Gone** — the client is told its successful upload failed, and clients like Uppy surface an error for an upload that actually completed.

## Reproduce

1. Register a listener on `tus-server.upload.complete` that processes the finished file and then deletes the upload's cache entry (e.g. `$cache->delete($key)`).
2. Complete an upload (final PATCH).
3. The PATCH response is 410 instead of 204, despite the file having been fully received and the listener having run successfully.

## Workaround we use

Defer cache retirement until after the response object is built, within the same request.

## Suggested fix

Snapshot the file/cache state needed for the response before dispatching the completion event, or document that the cache entry must outlive the event handler.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.