mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #8792] [MERGED] fix: enforce declared route rate limits and reclaim the stranded pnpm 10 store #8808
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#8808
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/8792
Author: @SpicyMarinara
Created: 11/3/2026
Status: ✅ Merged
Merged: 11/3/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/rate-limits-and-pnpm-store📝 Commits (3)
f7a006dfix(server): enforce declared route rate limits and match the routed path6185221fix(launcher): reclaim the pnpm 10 store stranded by the pnpm 12 switchb8665c5fix(server): keep a prefix root's trailing-slash HEAD in its GET bucket📊 Changes
6 files changed (+151 additions, -25 deletions)
View changed files
📝
packages/server/src/middleware/rate-limit.ts(+19 -15)📝
scripts/ensure-native-deps.mjs(+7 -1)📝
scripts/pnpm-runner.mjs(+15 -1)📝
scripts/regressions/pnpm-runner.regression.mjs(+36 -2)📝
scripts/regressions/route-rate-limits.regression.ts(+70 -6)📝
start-termux.sh(+4 -0)📄 Description
Linked issue
Closes #8791
Why this change
This fixes two release-prep audit findings.
(1) Routes added this release declare rate limits that were never enforced. The rate-limit hook only matched the raw URL against its own table, so /api/access/*, /api/notices, the utility sidecar, game rulesets, Beholder state and sprite rename all fell into the 600/min default. An absolute-form request line (
POST http://host/api/generate) also skipped every specific wall: generate, updates/apply, admin/restart and connection tests got 600/min, and /login was not throttled at all.(2) The switch to pnpm 12 leaves every existing checkout with a dead 2-3 GB .pnpm-store/v10 that
pnpm store prunecannot see. On Termux, the first pnpm 12 install can hit ENOSPC while both stores are on disk, and each later start then retries into the same full disk.There is no linked issue for either finding; one should be opened before the PR is submitted.
What changed
Behaviour change: a client above a route's declared rate now gets 429, where it used to pass under the shared 600/min default:
Absolute-form request lines now hit the same walls as normal requests.
The rate limiter matches its rule table against the route the router dispatched to, not the raw URL. Percent-encoded, duplicate-slash and absolute-form targets can no longer reach the 600/min default bucket.
Routes the table does not cover get their declared config.rateLimit in their own bucket per method and route pattern. HEAD shares GET's bucket, including Fastify's automatic HEAD route for a prefix root's trailing-slash form (HEAD /api/notices/). Existing shared table buckets are unchanged.
After a pnpm 11+ install, the root postinstall deletes the checkout's leftover pnpm 10 store (.pnpm-store/v10) and logs one line. This covers the launchers, the in-app updater, the Windows installer and manual installs. The first update from a pnpm 10 checkout still holds both stores during that install; v10 goes once it succeeds.
The Termux launcher removes .pnpm-store/v10 before it installs dependencies. If the first pnpm 12 install runs out of space, the next ./start-termux.sh frees v10 before retrying instead of failing again.
Regression coverage:
Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
curl --request-target http://127.0.0.1:7860/api/generate -X POST http://127.0.0.1:7860/returns RateLimit-Limit: 60.curl -I http://127.0.0.1:7860/api/notices/returns 429.Agent-run checks (for reference; each regression was shown to fail without its fix):
node ./scripts/pnpm-runner.mjs build:shared: succeedednode ./scripts/run-regressions.mjs --filter route-rate-limits (fix / previous commit's rate-limit.ts / origin/staging's rate-limit.ts, swapped by copying files: PASSED with the fix. FAILED against the previous commit (HEAD /api/notices/ shares the GET bucket). FAILED against staging (/api/access/pairing-codes got 200, expected 429).Reviewer's all-routes comparison (tsx, hooked onRoute over the real buildApp()), previous commit's selectRule vs the new one, 1317 method/route pairs: 2 differences, HEAD /api/notices/ and HEAD /api/avatar-models/, both now in their GET bucket at the declared limit. No other change.29 regressions run one at a time: route-rate-limits, encoded-api-path-security, basic-auth-throttle-security, remote-login, rate-limit-clock-jump, request-host-: all 29 passednode ./scripts/run-regressions.mjs --filter scripts/regressions/pnpm-runner.regression.mjs: passednode ./scripts/pnpm-runner.mjs --filter @marinara-engine/server lint (tsc -b ../shared && tsc --noEmit && tsc -p character-activity), with pipefail: exit 0tsc --ignoreConfig --noEmit --strict --module nodenext --target es2022 --skipLibCheck scripts/regressions/route-rate-limits.regression.ts: exit 0npx prettier --write then --check on rate-limit.ts and route-rate-limits.regression.ts: all files use Prettier styleEarlier round (unchanged files): pnpm-runner regression fails-before with all three or each wiring file reverted; launcher/ regressions, termux-sharp, dev-launc: passed as reported in the earlier round. 5 regressions timed out under load and passed on re-run alone. shellcheck is not installed.ESLint: not run: the repo's only ESLint config is packages/client/eslint.config.js, and no client files changedIndependent adversarial review: changes, 3 issue(s), all addressed in a fix-up pass.
Known limits and risks:
Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.