bun icon indicating copy to clipboard operation
bun copied to clipboard

Allow `MAX_HEADERS` to be configurable.

Open TomHennessy opened this issue 2 years ago • 4 comments

What is the problem this feature would solve?

Currently a system my team and I would like to migrate over is blocked by headers not being passed through. This is because there's a hard limit of 50 set here: https://github.com/oven-sh/bun/blob/131b96bbba3c2fc02b418e36a1ec0f9f7801171d/packages/bun-uws/src/HttpParser.h#L49C1-L49C1

Allowing this value to be configurable would allow us to increase it as we've audited the headers we're sending and we could get down only to around 70.

What is the feature you are proposing to solve the problem?

An optional config option that gives control over this constant.

What alternatives have you considered?

  • Upping the MAX_HEADERS value. This doesn't seem like a future proof solution.
  • We attempted to get down to below 50 headers but as it's a very large system it doesn't look possible without a major refactor.

TomHennessy avatar Nov 08 '23 10:11 TomHennessy

We should probably increase the default value, and adding some way to configure this makes sense.

Electroid avatar Nov 08 '23 18:11 Electroid

We should probably increase the default value, and adding some way to configure this makes sense.

That'd be great! Would you like me to create a PR for it? If so, what value sounds reasonable to increase it to?

I'll leave the configurability to you unless you're clear on how you'd like it done and could point me in that direction.

TomHennessy avatar Nov 09 '23 12:11 TomHennessy

@TomHennessy i wonder what response/return data was sent from bun when max_headers are reached?

trying to debug a similar issue, in my case it was "connection terminated"

morpig avatar Nov 28 '23 07:11 morpig

This has been bumped to 100 - but is still not configurable. We spent some time debugging 431 errors we're seeing in production code, do you think we could bump that limit?

There's no limitation for this in the HTTP spec - current limit: https://github.com/oven-sh/bun/blob/8dc084af5f2c23d3e97cdf955f525b2f84aa4206/packages/bun-uws/src/HttpParser.h#L20-L22

lbarthon avatar Dec 09 '25 23:12 lbarthon