Skip to content

feat(reports): a report's PDF can be 500 MB - #1700

Merged
sickerine merged 2 commits into
devfrom
feat/report-pdf-500mb
Dec 1, 2026
Merged

sickerine merged 2 commits into
devfrom
feat/report-pdf-500mb

Conversation

@sickerine

Copy link
Copy Markdown
Collaborator

A report's PDF can now be 500 MB, up from 100 MB. It uploads straight to R2 since #1699. The owner asked to make sure it can actually be read within the server's memory. Part of #1695.

Measured first

The dev backend runs every Node action in one Node 22 process, with the default 4 GB heap limit and about 2 GB already in use. The container has no memory limit, and the host had 88 GB free.

The repository's own code was run on generated 500 MB PDFs with that heap limit:

Step 100 pages 1,000 pages 4,000 pages of text
Reading (pdf.js) 201 MB heap, 1.6 GB in all 222 MB, 1.6 GB 516 MB, 2.0 GB
Byline page added 216 MB, 2.5 GB 219 MB, 2.1 GB 361 MB, 2.65 GB
Byline page, full rewrite 29 MB, 1.6 GB 38 MB, 1.6 GB 138 MB, 1.8 GB
Copy for the Zenodo deposit 6 MB, 1.9 GB 6 MB, 2.1 GB not run

Each step takes a few seconds. The memory is mostly the file's own buffers, which sit outside the heap limit.

What changes

  • Reports only. REPORT_PDF_MB = 500 sets the upload limit, attachPdf's refusal and the Publish page's check and hint. Extraction and the assistant keep 100 MB.
  • Large scans. A scan, which has no text, past 100 MB is no longer given to the model whole: its base64 would pass what a string can hold. Its reading ends as unread and the author types the details. Below 100 MB nothing changes.
  • One copy. A PDF read from R2 for the reading or the checks is held once, in R2's answer, not copied into a Blob first.

Checks

  • npx tsc --noEmit, check:convex-rules
  • npx vitest run convex/reports convex/files convex/migrations lib/reports: 308 passed, including a new test that a scan past the limit sends nothing to the model

After merge

A 500 MB PDF gets uploaded and read on dev in a browser, with the backend's memory watched while it runs.

Measured on 500 MB PDFs of 100, 1,000 and 4,000 pages under the backend's 4 GB heap: reading, the byline page and
its full rewrite take at most 516 MB of heap and 2.65 GB of memory in all, a few seconds each. Only reports change:
extraction and the assistant keep their 100 MB.

A scan past 100 MB, which has no text to read, is no longer given to the reader whole, whose base64 would pass what a
string can hold: the author types its details in. A PDF read from R2 is held once, in the answer's own buffer.

Part of #1695.
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e344575e-a82c-4e40-b538-c668a6639843
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-01T23:40:22.823513Z ad9e0e4 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ad9e0e4335

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread convex/reports/reading.ts Resolved
@sickerine
sickerine merged commit 51afaac into dev Dec 1, 2026
6 checks passed
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.

1 participant