Skip to content

fix: race condition causing GZIP corruption on restart - #548

Merged
QuiteAFancyEmerald merged 1 commit into
QuiteAFancyEmerald:masterfrom
yetval:fix/gzip-race-and-kill-481
Apr 18, 2026
Merged

fix: race condition causing GZIP corruption on restart#548
QuiteAFancyEmerald merged 1 commit into
QuiteAFancyEmerald:masterfrom
yetval:fix/gzip-race-and-kill-481

Conversation

@yetval

@yetval yetval commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #481

As requested, here's the fix for the restart race condition. Found some more bugs on the way:

  • Build now writes to views/dist-new and atomically renames to views/dist on completion, eliminating the window where the server could serve plain HTML with a gzip Content-Encoding
  • npm run kill now uses npx pm2 kill; pkill -f "node backend.js" || true instead of pkill node, which was killing the pm2 daemon and leaving nginx with stale connections
  • Skip paintSource on vendor scram bundles to fix intermittent esbuild failures on repeated builds

@QuiteAFancyEmerald
QuiteAFancyEmerald merged commit 49459a5 into QuiteAFancyEmerald:master Apr 18, 2026
2 checks passed
@QuiteAFancyEmerald

Copy link
Copy Markdown
Owner

After further testing this did not seem to resolve the issue. npm run kill also shouldn't be replaced since its current behavior makes sense versus killing all of pm2 on the VPS. Made some corrections that broke scramjet assets as well. The rename feature is essentially the only thing leftover. As usual the solution is before so I am opening the issue again.

GZIP Gibberish Fix:

  • Delete node_modules
  • Delete /dist
npm run kill
npm run fresh-start
sudo rm -rf /var/cache/nginx/* 
sudo nginx -t 
sudo systemctl reload nginx

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.

Force restarting creates maximum GZIP gibberish (Nginx)

2 participants