Skip to content

Fix corrupted raw data downloads for large exports - #120

Merged
Yazito21 merged 1 commit into
mainfrom
fix/raw-export-truncated
Dec 4, 2026
Merged

Yazito21 merged 1 commit into
mainfrom
fix/raw-export-truncated

Conversation

@Yazito21

@Yazito21 Yazito21 commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Cause

export-raw-responses sends HTTP 200 and then streams the workbook. For Dr D (4,113 responses) the function hit CPU Time exceeded (2,018 ms) and was stopped mid-stream. The saved file ends inside the first sheet at row 2,687, with no zip directory, so Excel rejects it.

Fix

  • The workbook is built in the browser (lib/raw-export.ts), reading under the user's row-level security. Same sheets and columns.
  • The file is saved only when complete; failed or short reads show an error.
  • Excel limits: at most 65,530 hyperlinks per sheet, valid link targets, no split surrogate pairs, Responses page export shortens values over 32,767 characters.
  • Removes the Edge Function source. The deployed function is no longer called.

Testing

  • Unit tests in lib/raw-export.test.ts (77 lib tests pass), tsc passes.
  • Writer run on the 2,686 responses recovered from the broken file, repeated to 4,113: opens in openpyxl and LibreOffice, about 3.2 s of CPU in Node.
  • Not click-tested signed in.

Generated by Claude Code

The export-raw-responses Edge Function streamed the workbook after already
answering 200. Large exports exceeded the function's 2 second CPU limit, the
worker was stopped mid-stream, and the browser saved a truncated file that
Excel reported as corrupted.

The workbook is now built in the browser with the same sheets and columns. It
is only saved once complete, and a failed or short read shows an error. Also
guards against Excel's hyperlink and cell limits and split surrogate pairs.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011zdoJUrqnkRrxhSVaRvd1X
@vercel

vercel Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lifecite-ai Ready Ready Preview Dec 4, 2026 8:26am UTC

@Yazito21
Yazito21 merged commit 3e6d85e into main Dec 4, 2026
6 checks passed

This branch was successfully deployed

1 active deployment
Preview — 1648fda6 Deployed Dec 4, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants