Skip to content

Harden Node adapter HTTP server defaults and request body handling#15759

Merged
matthewp merged 7 commits intomainfrom
fix/bugbot-129
Mar 5, 2026
Merged

Harden Node adapter HTTP server defaults and request body handling#15759
matthewp merged 7 commits intomainfrom
fix/bugbot-129

Conversation

@matthewp
Copy link
Contributor

@matthewp matthewp commented Mar 4, 2026

Changes

  • Adds a global body size limit to createRequest() that enforces a maximum request body size via a streaming size-limiting wrapper
  • The Node adapter's createAppHandler applies a default 1GB body size limit to prevent unbounded memory consumption
  • Adds new bodySizeLimit option in the adapter, ex. node({ bodySizeLimit: Infinity }) sets to no limit

Testing

  • Added unit tests for body size limiting in packages/astro/test/units/app/node.test.js:
    • Verifies request body exceeding the limit is rejected
    • Verifies request body within the limit is accepted
    • Verifies no limit is enforced when bodySizeLimit is not configured

Docs

@changeset-bot
Copy link

changeset-bot bot commented Mar 4, 2026

🦋 Changeset detected

Latest commit: de0fbb8

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: integration Related to any renderer integration (scope) pkg: astro Related to the core `astro` package (scope) labels Mar 4, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 4, 2026

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing fix/bugbot-129 (de0fbb8) with main (631aaed)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (2ff96f4) during the generation of this report, so 631aaed was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@matthewp matthewp marked this pull request as ready for review March 4, 2026 17:22
@matthewp matthewp marked this pull request as draft March 4, 2026 17:23
matthewp added 2 commits March 5, 2026 11:00
# Conflicts:
#	packages/astro/src/core/app/node.ts
#	packages/integrations/node/src/serve-app.ts
Copy link
Member

@sarah11918 sarah11918 left a comment

Choose a reason for hiding this comment

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

Changeset LGTM!

(I think in the past we've done things like split the patch and minor up, so that e.g. the patch is only about the timeout stuff, and the minor is only about the new config option. If you think it's fine to combine them like this, then it's good as written!)

Co-authored-by: Sarah Rainsberger <5098874+sarah11918@users.noreply.github.com>
* Wraps an async iterable with a size limit. If the total bytes received
* exceed the limit, an error is thrown.
*/
async function* limitAsyncIterable(
Copy link
Member

Choose a reason for hiding this comment

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

Aren't generators slow?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Iterables are comparitively, but there already is an iterable here (the request).

@matthewp matthewp merged commit 39ff2a5 into main Mar 5, 2026
26 checks passed
@matthewp matthewp deleted the fix/bugbot-129 branch March 5, 2026 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants