nextcloud / nextcloud/text

Handle large text files that would exhaust php memory_limit

Open
#7,814 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

1. to develop bug papercut performance 🚀
Dominant language
JavaScript
Stars
659
Forks
133
Avg merge
1d 20h
Merged PRs (30d)
110

Description

[!NOTE]

  • Currently exhausts PHP memory_limit
  • Near term: Reject > X MB (e.g. memory_limit-128 or, safer, min(memory_limit-128, 100)
  • Longer term: Implement streaming if deemed desirable

Large text files can exhaust the php memory limit when opened:

{"app":"PHP","method":"PUT","url":"/index.php/apps/text/session/9999578225/create","message":"Allowed memory size of 2147483648 bytes exhausted (tried to allocate 2900994904 bytes) at /var/www/nextcloud_32/lib/private/Files/Storage/Local.php#294"}

In the UI, this leads to a mostly white page with a generic error symbol at the bottom (screenshot below).

To Reproduce
Steps to reproduce the behavior:

  1. Generate & upload text file larger than php memory limit, for example with:
    dd if=/dev/urandom bs=1M count=2048 | base64 > large.txt
  2. Open file in the text editor, either as a logged in user or via a public share link

Expected behavior
Ideally - but probably difficult to implement -the file would be opened and displayed in chunks.

Alternatively, some configurable cutoff file size after which a clear error such as "file too large" is displayed to the user would be helpful.

For comparison, the onlyoffice editor has a configurable maxDownloadBytes parameter that defaults to 100M.

Screenshots
Image

Server details:

  • Nextcloud version: Nextcloud 31.0.8 EE, also reproduced with 32.0.0 CE.
  • PHP Version: 8.2-fpm
  • Database: MariaDB 10.11

Client details:

  • Chrome 141 @ OpenSUSE Leap 16 (and others)
Logs
Nextcloud log (data/nextcloud.log)
{"app":"PHP","method":"PUT","url":"/index.php/apps/text/session/9999578225/create","message":"Allowed memory size of 2147483648 bytes exhausted (tried to allocate 2900994904 bytes) at /var/www/nextcloud_32/lib/private/Files/Storage/Local.php#294"}
Browser console
Failed to load resource: the server responded with a status of 500 ()

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the text session create endpoint in the logs and inspect lib/private/Files/Storage/Local.php around line 294 to trace how large files are opened. Reproduce with the provided dd command and verify that oversized files no longer exhaust PHP memory and instead produce a clear user-facing error; streaming remains a separate longer-term option.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, php
Domain
backend, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.