Jatin917/riverside-clone

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

Open

#11 opened on Jul 8, 2025

 (0 comments) (0 reactions) (1 assignee)TypeScript (0 forks)auto 404
bugenhancementgood first issue

Repository metrics

Stars
 (4 stars)
PR merge metrics
 (PR metrics pending)

Description

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)

Contributor guide