Skip to content

Conversation

@wxiaoguang
Copy link
Contributor

No description provided.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 11, 2025
@github-actions github-actions bot added the modifies/go Pull requests that update Go code label Nov 11, 2025
@wxiaoguang wxiaoguang added this to the 1.26.0 milestone Nov 11, 2025
@ChristopherHX
Copy link
Contributor

I would possible tend to create a single file listing these limits as constant's, so finding them becomes slightly more structured.

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented Nov 11, 2025

I would possible tend to create a single file listing these limits as constant's, so finding them becomes slightly more structured.

Although I also thought about the "constants", but I didn't find a proper package to contain them. And the more changes we made here, the more potential conflicts when backporting.

At the moment, ReadWithLimit should be easy enough to find them.

@ChristopherHX
Copy link
Contributor

I understand your point, will try this out tomorrow. I can currently not estimate how this constraints will become visible to me in the UI / api.

@wxiaoguang
Copy link
Contributor Author

wxiaoguang commented Nov 12, 2025

I can currently not estimate how this constraints will become visible to me in the UI / api.

There should be no "visible effect" in daily usage.

When a file exceeds the limit, it will be only partially read (no error).

In most cases, I used 1M (1024*1024), it should be large enough for a workflow file or a template file. I can't imagine how a normal file can exceed that limit.

Update: BTW: this PR is not related to Abnormal memory usage when reading large workflow log files #35925

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Nov 12, 2025
@wxiaoguang
Copy link
Contributor Author

Doesn't block 1.25.2 release, no need to wait for this.

Copy link
Member

@delvh delvh left a comment

Choose a reason for hiding this comment

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

Let's hope that 1MB is really large enough that no user ever encounters it.
If not, we can still adjust the limits.

}
defer reader.Close()
content, err := io.ReadAll(reader)
content, err := util.ReadWithLimit(reader, 5*1024*1024) // 5MB should be enough for a wiki page
Copy link
Member

Choose a reason for hiding this comment

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

Actually, I can imagine one case where a wiki page needs more:
<img src="data:image/png;base64,…">

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure 🤷

So maybe 5M, 10M, 50M, 100M .....

But I guess there is a "general" limit that most browsers will stop responding when the content is large enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

Chrome Mobile, doing it far more early than Chrome Desktop this limit UI responsive limit is artificial.

Loading the data works in most cases if below 4GB at least on desktop, but displaying not without extremely cautious paging out text from the html dom (scrolling is a problem then as well) e.g. place holder or help of SPA frameworks that do it for you.

Displaying CI logs in browsers without truncation is a challenge.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Nov 12, 2025
@wxiaoguang
Copy link
Contributor Author

Let's hope that 1MB is really large enough that no user ever encounters it.

IMO 1M is large enough in all cases.

As large as QuickJS (about 59K lines): https://github.com/bellard/quickjs/blob/master/quickjs.c#L58923 , it is 1.85MB

Copy link
Contributor

@ChristopherHX ChristopherHX left a comment

Choose a reason for hiding this comment

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

I would actually record an enhancement to report a failure for workflows exceeding the limit.

Currently a subset of the workflow might run and you have trouble to understand why jobs, steps or properties are missing and why sometimes the workflow just do not trigger because of a yaml syntax error.

}
defer reader.Close()
content, err := io.ReadAll(reader)
content, err := util.ReadWithLimit(reader, 5*1024*1024) // 5MB should be enough for a wiki page
Copy link
Contributor

Choose a reason for hiding this comment

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

Chrome Mobile, doing it far more early than Chrome Desktop this limit UI responsive limit is artificial.

Loading the data works in most cases if below 4GB at least on desktop, but displaying not without extremely cautious paging out text from the html dom (scrolling is a problem then as well) e.g. place holder or help of SPA frameworks that do it for you.

Displaying CI logs in browsers without truncation is a challenge.

@wxiaoguang
Copy link
Contributor Author

I would actually record an enhancement to report a failure for workflows exceeding the limit.

At the moment I can't imagine a workflow file exceeds 1MB ....

Currently a subset of the workflow might run and you have trouble to understand why jobs, steps or properties are missing and why sometimes the workflow just do not trigger because of a yaml syntax error.

I think " Improve online runner check #35722 " started the initial supports for similar cases?

@wxiaoguang wxiaoguang merged commit 372d24b into go-gitea:main Nov 12, 2025
25 checks passed
GiteaBot pushed a commit to GiteaBot/gitea that referenced this pull request Nov 12, 2025
@wxiaoguang wxiaoguang changed the title Limit read bytes instead of ReadAll Limit reading bytes instead of ReadAll Nov 12, 2025
@GiteaBot GiteaBot added the backport/done All backports for this PR have been created label Nov 12, 2025
@wxiaoguang wxiaoguang deleted the fix-read-all branch November 12, 2025 11:45
wxiaoguang added a commit that referenced this pull request Nov 12, 2025
Backport #35928 by wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/done All backports for this PR have been created backport/v1.25 lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/frontend modifies/go Pull requests that update Go code type/bug

5 participants