Skip to content

fix: pass the real method to adapter admission in fastify and skip body re-encoding - #224

Merged
thegdsks merged 3 commits into
release/wave6-2026-10from
perf/admit-light-request
Oct 13, 2026
Merged

thegdsks merged 3 commits into
release/wave6-2026-10from
perf/admit-light-request

Conversation

@thegdsks

Copy link
Copy Markdown
Member

Found while checking the admission code path.

Bug

Fastify's toWebRequest hardcoded method: "GET". Since guard.admit reads the method, every Fastify write was counted in the read tier and the cross-site check (unsafe methods only) never ran. The Fastify adapter had the rate limit and CSRF code but not the behavior. The earlier express and hono tests did not cover Fastify.

Changes

  • Fastify passes request.method.
  • Express and NestJS skip re-encoding the parsed JSON body when building the request for admit, which only reads headers. That body was serialized again on every request for nothing.
  • New Fastify admission tests: writes do not consume the read tier, and a cross-site cookie write is a 403.

Verified

I put the old method: "GET" back and both new Fastify tests fail, then restored the fix and they pass. Fastify 22, Express 56 and NestJS 19 adapter tests pass, tsc clean in all three.

Not verified

No benchmark of the saved body encoding.

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your first pull request. CI will run shortly. If the change touches package source, please add a changeset with pnpm changeset.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
25.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@thegdsks
thegdsks merged commit bd5fe00 into release/wave6-2026-10 Oct 13, 2026
6 of 7 checks passed
@thegdsks
thegdsks deleted the perf/admit-light-request branch October 13, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant