Skip to content

fix(upload): 404 for a block whose upload no longer exists #279

Closed

Description

@LouisHaftmann

Problem

Storage.uploadPart returns early when no uploads row matches the id (lib/storage.ts:335):

if (!upload) return

The block route (routes/devstoreaccount1/upload/[uploadId].put.ts) then answers 201 as if the block was stored. The client keeps going, and the missing part only shows up later as a failed finalize or a broken restore, with nothing in the logs pointing at the dropped block.

The row can be gone while a client is still uploading:

  • cleanup:uploads deletes uploads whose last finished part is older than one minute, so a client that pauses between blocks or has one slow block can lose its upload.
  • completeUpload deletes the row, so a retried or late block after finalize hits this path.
  • abandonUpload deletes it after a failed part.

Proposed fix

Throw a 404 from the route when the upload does not exist, so the client sees the failure on the block that caused it. Add a test: a PUT to an unknown upload id returns 404 and writes nothing to storage.

Related: #275 touches the same route but leaves this behavior unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions