Short answer: make retention and deletion the system of record, then choose single-request or multipart transfer based on the largest restart you can tolerate. For a gaming service storing AI-generated PNG and WebP images, a timeout is a lifecycle problem before it is a networking problem.
The useful experiment is small. Give one tenant three generated images, attach two of them to a selected game snapshot, interrupt an upload halfway through, and run the retention job while a restore is starting. A naive design usually makes one of two mistakes: it treats an object key as the business record, or it deletes bytes because an upload session looks old. The design below keeps those decisions separate.
Before copying it, measure the largest image, the proxy idle limit, the retry rate, and how much repeated transfer your players' networks produce. I’m not sure any fixed part size deserves to survive contact with your traffic.
A tenant asset has two clocks
Store two records, with different owners and clocks. The image record represents a durable tenant asset or snapshot member. The upload record represents temporary transport work. Neither should be reconstructed from a filename.
An image record needs a tenant ID, image ID, format, byte size, creation time, logical snapshot ID, retention class, object key, and deletion state. An upload record needs its own ID, image ID, upload ID, expected size, part size, expiry, completed part identifiers, and status. This gives the retention worker something precise to select and gives the retry path enough information to resume.
The distinction matters during restore. A browser should request a snapshot ID that the server authorizes for its tenant; it should not choose an arbitrary object key. The restore operation can create a short-lived restore record pointing to that snapshot. Deletion then has a concrete rule: an eligible snapshot with an active restore reference is not ready for physical removal.
This is also the simplest way to make a timeout explainable. A client timeout, reverse-proxy idle limit, application request limit, and storage request timeout are separate clocks. Log a correlation ID, tenant ID, image ID, upload ID, part number, attempt number, elapsed time, and response status. Keep image bytes and credentials out of those logs.
Can a large PNG or WebP upload survive a Node.js timeout?
Retention should answer two questions: how long may a player restore a snapshot, and when may its physical bytes be removed? The first is policy. The second is a coordinated operation that must account for references, incomplete work, and retries.
Use explicit states such as uploading, completed, expired, deleting, and deleted. A generated image becomes publishable only after completion has been confirmed and its metadata has been checked. An expired multipart session is abandoned transport work; it is not proof that a completed snapshot is disposable.
There is a race worth putting in a test. The cleanup scan reads session A as uploading; the final part arrives; completion creates snapshot B; cleanup continues. A second state check must see the completion and leave the object alone. The equivalent restore race is selection, then restore-reference creation, then deletion. If those operations cannot share one transaction, use an intermediate deletion state and a reconciliation pass instead of pretending they can.
For uploads, set an expiry on the session and let a scheduled worker select expired sessions. The worker should re-check status, ask the configured storage adapter to abort the session, record the attempt, and mark the session expired only after the application state is still compatible with that action. Repeatable cleanup is a feature. It should be safe to run again after a process stop.
File validation belongs before this lifecycle begins. OWASP recommends an allowlist, size limits, type validation, safe generated names, and storage outside a directly served web root or behind controlled access. PNG and WebP are allowed formats, not evidence that a filename is trustworthy.
The catch is policy overhead. A retention ledger, restore reference, cleanup worker, and reconciliation pass are not suitable for a throwaway thumbnail with no restore requirement. For that case, use the smallest workflow that meets the measured timeout budget. Keep the ledger for tenant snapshots whose deletion or restore outcome matters.
The deletion race needs a test fixture
The most revealing fixture is not a synthetic “upload succeeded” assertion. It is a timeline with two tenants and one selected snapshot: tenant north starts a 180 MB PNG, records parts 1 through 3, loses the worker after part 3, and asks for a restore while tenant south has an expired session for a different WebP. The cleanup worker reads both sessions before either callback returns. Then north completes and creates a restore reference while south is still eligible for abort. The expected result is asymmetric: north’s object remains available because its snapshot and restore reference now exist; south’s temporary session is cleaned up because it has no completed snapshot. Assert the tenant IDs at every transition, the status written after each external call, the 408 classification if the transport times out, the provider response recorded for each part, and the fact that a second cleanup run changes nothing. This one fixture catches accidental cross-tenant selection, deletion based on stale scans, and code that confuses a provider upload ID with a durable snapshot ID. I classify the 408 as a transport event, not as evidence that the image should be deleted.
Short tests beat heroic retries.
Multipart is an implementation detail
Multipart is a recovery choice. It is useful when an interrupted transfer would restart too much of a large generated image, but it introduces an upload ID, part numbering, a completion manifest, and abandoned-session cleanup. A single request is easier to operate when its worst-case retry fits the request budget.
The adapter should hide provider-specific calls behind a narrow interface. The application still owns tenant authorization, expected format, expected byte size, retention, and the transition to completed. This separation lets a storage migration preserve snapshot identity instead of treating a new provider object as a new game asset.
Here is the part of the experiment that is worth making deterministic. The same part number is retried through the same upload session, and the completion manifest is sorted before it crosses the adapter boundary.
type ImageFormat = "png" | "webp"; type PartReceipt = { partNumber: number; providerPartId: string; }; type UploadSession = { tenantId: string; imageId: string; uploadId: string; format: ImageFormat; sizeBytes: number; partSizeBytes: number; expiresAt: string; completedParts: PartReceipt[]; }; async function uploadMissingParts( file: Blob, session: UploadSession, putPart: (input: { uploadId: string; partNumber: number; body: Blob; }) => Promise<string>, ): Promise<PartReceipt[]> { if (file.size !== session.sizeBytes) { throw new Error("file size does not match the upload session"); } const receipts = new Map( session.completedParts.map((part) => [part.partNumber, part]), ); const totalParts = Math.ceil(file.size / session.partSizeBytes); for (let partNumber = 1; partNumber <= totalParts; partNumber += 1) { if (receipts.has(partNumber)) continue; const start = (partNumber - 1) * session.partSizeBytes; const end = Math.min(start + session.partSizeBytes, file.size); const providerPartId = await putPart({ uploadId: session.uploadId, partNumber, body: file.slice(start, end), }); receipts.set(partNumber, { partNumber, providerPartId }); } return [...receipts.values()].sort( (left, right) => left.partNumber - right.partNumber, ); } The completion endpoint should validate the session tenant, expiry, expected format, expected size, and complete manifest before changing the image record. It should be idempotent at the application boundary. A successful part response does not mean the image is ready for a restore.
Retries should be bounded and limited to transient transport failures. I don’t retry an authorization or validation rejection; repeating it only obscures the decision the caller must make. Your mileage may vary on the retry cap, so record attempt duration and repeated bytes instead of borrowing a number from a different network.
The retention ledger closes the loop
Start with the failing state transition, not the phrase “upload timeout.” A part that exceeds an idle limit points to part size, request duration, or proxy settings. A rejected completion points to the session or manifest. A restore that cannot read an object points to authorization, object identity, or deletion state.
| Symptom | Inspect first | Decision to test |
|---|---|---|
| One part exceeds the request budget | part size and idle limit | reduce the restart unit or raise the permitted duration |
| The same part repeats | receipt persistence and retry classification | resume from the recorded part, not byte zero |
| Completion is rejected | tenant, expiry, size, and ordered manifest | repair application state before retrying |
| A restore target is missing | snapshot reference and deletion state | pause deletion until references reconcile |
For each format and size class, measure p50 and p95 part duration, completion duration, retry rate, repeated bytes, abandoned sessions, expiry age, and restore latency. Test the largest expected image, a slow connection, a process stop after a successful part, an incomplete manifest, and cleanup concurrent with completion. A green upload test is not a deletion test.
The release decision should fit on one page: maximum object size, upload mode, session expiry, retention rule, deletion owner, authorization checks, and the test proving one tenant cannot complete, restore, list, or delete another tenant’s asset. That document is more useful than a vendor comparison because it survives a storage migration.
Three words: prove deletion first.


