[Bug]: File share retains full file buffers in RAM indefinitely causing V8 heap exhaustion
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- node.js, typescript
- Domain
- backend, distributed-systems
Research direction
Start with src/server/signalling/handlers/fileShare.ts and trace how uploaded files are stored and how GET /api/files/download serves them. The issue identifies the desired behavior: retain metadata and a disk path, release file buffers after saving, and stream downloads from disk. A pull request is already open against this issue; check its changes and status before taking it on.
Written by the indexing model from the issue text.
Description
Bug Description
In src/server/signalling/handlers/fileShare.ts, fileStore = new Map<string, SharedFile>() retains full in-memory file buffers (data: Buffer) in RAM indefinitely, even after the file has already been saved to the host disk. Because Rein permits file uploads up to 512 MB (MAX_FILE_BYTES = 512 * 1024 * 1024), uploading 2–3 files quickly exhausts the Node.js V8 heap (~1.4 GB to 2 GB) and causes the server process to crash with FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory, disconnecting all active WebRTC sessions.
Furthermore, downloading files by fileId via GET /api/files/download?fileId=<id> served the file using res.end(file.data), bypassing stream backpressure.
Steps to Reproduce
- Start the Rein server.
- Upload two large files (e.g., 400–500 MB video/archive files) via
/api/files/upload. - Observe Node.js memory footprint ballooning over 1.5 GB.
- Server crashes with JavaScript heap out of memory error.
Expected Behavior
- Uploaded file data should be written to host disk and released from memory immediately for garbage collection.
fileStoreshould only hold metadata and the local file path.fileIddownloads should stream file chunks directly from disk usingfs.createReadStream.
Desktop Operating System
Windows 11
Client OS and browser
Any (iOS Safari, Android Chrome, desktop browser)
Rein Version
1.0.0
Console Logs / Error Messages (Optional)
Screenshots / Recordings (Optional)
No response
Checklist
- I have searched for existing issues to avoid duplicates
- Dominant language
- TypeScript
- Stars
- 55
- Forks
- 120
- Avg merge
- 4d 5h
- Merged PRs (30d)
- 24
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from AOSSIE-Org/Rein
-
[Bug]: JSON body null returns 500 on /api/clipboard/copy and /api/clipboard/pastePossibly taken A pull request linked to this issue is open or already merged. Openbug enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
AOSSIE-Org/Rein#522 · 1 comment ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
AOSSIE-Org/Rein#509 · 3 comments ·
Maintainers usually reply within 2 days
-
[Bug]: Session tokens expire 10 days after creation regardless of use (touchToken is never called)Possibly taken @Ankitavasudev claimed this 12 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
AOSSIE-Org/Rein#466 · 6 comments · 1 assignee ·
Maintainers usually reply within 2 days
-
[Bug]: Uploaded files are saved with garbled non-ASCII names and overwrite existing files with the same namePossibly taken @Aryan-en claimed this 23 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
AOSSIE-Org/Rein#458 · 5 comments ·
Maintainers usually reply within 2 days
-
[Bug]: Missing WebRTC playoutDelayHint introduces 50-100ms artificial latency and redundant MediaStream recreation triggers video pipeline reloadPossibly taken @MPoojaSiyag claimed this 1 day ago. Openbug enhancement
Difficulty 3/5 1-2 days Newbie friendliness 35/100
AOSSIE-Org/Rein#523 · 1 comment ·
Maintainers usually reply within 2 days
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 75/100
-
review-followup
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
griffinwork40/agent-afk#5387 ·
Maintainers usually reply within 1 day
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
CodeManufactoryLLC/Code60#358 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
android:plan ios:plan main:plan packages:learn
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day