Wed 21 May 2025
Forgejo index.js woes
I've run a few small git forges that've gone through the various fork paths over the years, from Gogs to Gitea to (now) Forgejo. It all runs remarkably well and has been mostly set-and-forget for as long as I can remember, and easily trumps the few times I've had to deal with self hosting something like Gitlab. One weird issue would come and go over the years, though: on first load of a page for Gitea and Forgejo, I'd randomly get an alert about being unable to load the core JS file.
If you just reloaded the page, things would work fine - and frankly that was simpler than bothering to debug it when it appeared. Presumably, the file was just getting cached somehow and subsequent loads would not have issues. I had a few minutes earlier this week to debug it and figured I'd note it down for anyone who's getting confused by it. In my case, this error was actually specific to nginx as a reverse proxy sitting in front of everything.
The Fix
When nginx is proxying a response that's deemed too large, it attempts to buffer it in temporary file. For whatever reason, on my stock Debian 12 image nginx did not have the right permissions to do this. A simple chown
to the user that nginx runs under fixes this:
sudo chown -R www-data:www-data /var/cache/nginx
This error as presented in the browser can be confusing; if you have http2
enabled on your host, Chrome & co will report it as an http2 specific issue. If you disable that, it correctly reports it as invalid chunking - i.e, the response is being interrupted due to nginx not being able to write when proxying.