Skip to content

Add Timeout and Progress Feedback for Large CSV File Processing #52

@pragmaticAweds

Description

@pragmaticAweds

Context & Impact

In csv-processing.ts, the file size is validated at 1MB max, but the file.text() call that reads the file content has no timeout. For files approaching the 1MB limit with thousands of rows, parsing can take several seconds. During this time, the user sees no progress indicator, no loading state, and no way to cancel. If the file is malformed, the parser may hang or take excessively long.

Why this matters: Users uploading CSV files for bulk token distribution expect immediate feedback. A file with 10,000 recipients is a legitimate use case, but the current implementation provides no indication that processing is happening. Users may think the upload failed and try again, or navigate away before processing completes.

Scope

  • Add a loading state to the CSV upload flow with a progress indicator
  • Add a timeout for the file.text() call (10 seconds max)
  • Show row count feedback as the CSV is parsed ("Processing 5,000 recipients...")
  • Add a cancel button to abort long-running CSV processing
  • Validate CSV structure (headers, column count) before processing all rows
  • Show specific error messages for common CSV issues (wrong delimiter, missing columns)

Implementation Guidelines

  • Wrap file.text() with Promise.race() against a timeout promise
  • Add a processingState to the upload component: 'idle' | 'reading' | 'parsing' | 'validating' | 'complete' | 'error'
  • Show a progress bar or spinner during the reading and parsing phases
  • Parse the CSV header row first and validate column names before processing data rows
  • For very large files, consider using a streaming parser or Web Worker to avoid blocking the main thread
  • Use the existing FileUploadArea.tsx component for the UI updates

Acceptance Criteria

  • A loading spinner/progress indicator shows during CSV processing
  • Files approaching 1MB show "Processing X recipients..." feedback
  • A 10-second timeout prevents indefinite hangs on malformed files
  • Users can cancel CSV processing mid-way
  • CSV header validation catches wrong column names before processing rows
  • Specific error messages for: wrong delimiter, missing required columns, empty file
  • Successfully processed CSV shows "X recipients loaded" confirmation
  • The upload area is disabled during processing (no duplicate uploads)

Getting Started

  1. Read src/utils/csv-processing.ts — understand the current parsing flow
  2. Read src/components/molecules/FileUploadArea.tsx — understand the upload UI
  3. Add timeout wrapper: Promise.race([file.text(), timeoutPromise(10000)])
  4. Add processingState to the upload component
  5. Add header validation before processing data rows
  6. Add progress feedback UI (spinner + row count)
  7. Test with: empty file, 10-row file, 1000-row file, malformed CSV, wrong delimiter

PR Submission Guide

This section applies to every PR for this issue. Follow it exactly.

Before You Start

  • Fork the repository first if you haven't already — all contributions must come from a fork
  • Pull the latest main branch: git checkout main && git pull origin main
  • Create your feature branch from main: git checkout -b feat/<issue-number>-csv-processing-feedback

While Working

  • Make atomic commits — one concern per commit, each commit must build
  • Use Conventional Commits: feat(scope): description, fix(scope): description
  • Keep your branch up to date: git pull origin main --rebase regularly

Before Submitting the PR

  • Pull latest main and rebase: git checkout main && git pull origin main && git checkout <your-branch> && git rebase main
  • Ensure the build passes: pnpm build
  • Ensure linting passes: pnpm lint
  • Record a screen recording of your implementation showing the feature/fix working in the browser. Attach it to the PR.

PR Requirements

  • Link this issue in your PR description using Closes #<issue-number>
  • Fill out the full PR template — Summary, What Was Implemented, Implementation Details, How to Test
  • Attach your screen recording demonstrating the implementation
  • Request a review from a maintainer

PRs without a screen recording or without a linked issue will not be reviewed. Failure to meet PR requirements may lead to PR rejection.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions