Jatin917/riverside-clone

## 🧠 Improvement Suggestion: Use a Real Queue Structure in IndexedDB

Aperta

#11 aperta il 8 lug 2025

 (0 commenti) (0 reazioni) (1 assegnatario)TypeScript (0 fork)auto 404
bugenhancementgood first issue

Metriche repository

Star
 (4 stelle)
Metriche merge PR
 (Metriche PR in attesa)

Descrizione

Description

Currently, the queue object store in IndexedDB is implemented as a flat list of chunk metadata objects. While this works for basic uploads, it lacks true queue behavior — specifically the ability to reorder chunks when upload fails.

Problem

If a chunk fails to upload during processQueue(), it cannot be repositioned at the end of the queue. This results in repeatedly retrying the same chunk first in every cycle, while newer chunks are blocked behind it.

Suggested Enhancement

Use an actual queue-like data structure in IndexedDB, with the ability to:

  • Insert new chunks at the end
  • Retry failed chunks by moving them to the end
  • Maintain order of processing but avoid hard-stopping on failure

Possible Implementation

  • Maintain an additional position or timestamp field in each queued item
  • Sort by position before processing
  • On upload failure, update position to the latest to push it to the back

Benefits

  • Reduces bottlenecks from one bad chunk
  • Improves overall upload flow and responsiveness
  • Prepares system for more intelligent queueing strategies (e.g., retry limits, prioritization)

Guida contributor