Skip to content

Conversation

@gammazero
Copy link
Contributor

Added a configurable fallback timeout for the gateway handler, defaulting to 1 hour. Configurable via MaxRequestDuration in the gateway config.

Replaces #1069

@gammazero gammazero requested review from a team and lidel as code owners December 13, 2025 03:56

// MaxRequestDuration per-request timeout for the gateway handler. It
// defaults to DefaultMaxRequestDuration.
MaxRequestDuration time.Duration
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this need to be a duration string that can be parsed (e.g. "1h")?

Copy link
Member

Choose a reason for hiding this comment

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

That is up to the user of boxo/gateway library.
Prior art (RetrievalTimeout time.Duration) in Kubo is wired in a way that support human-readable strings, but that is userland decision, we dont do that in boxo here.

Added a configurable fallback timeout for the gateway handler, defaulting to 1 hour. Configurable via `MaxRequestDuration` in the gateway config.

Replaces #1069
@gammazero gammazero force-pushed the config-gw-request-timeout branch from 110dc2d to 8e2e90a Compare December 13, 2025 03:58
@codecov
Copy link

codecov bot commented Dec 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 61.08%. Comparing base (12e077c) to head (57332a8).
⚠️ Report is 1 commits behind head on main.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1079      +/-   ##
==========================================
- Coverage   61.14%   61.08%   -0.06%     
==========================================
  Files         264      264              
  Lines       26227    26231       +4     
==========================================
- Hits        16036    16024      -12     
- Misses       8515     8525      +10     
- Partials     1676     1682       +6     
Files with missing lines Coverage Δ
gateway/gateway.go 79.22% <100.00%> (+1.13%) ⬆️
gateway/handler.go 77.91% <100.00%> (ø)

... and 11 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

gammazero and others added 3 commits January 8, 2026 07:00
- fix typo in error message (MaxRequestDuratio -> MaxRequestDuration)
- clarify difference between MaxRequestDuration and RetrievalTimeout
- document that zero/negative values use the default
- add unit tests for validateConfig with MaxRequestDuration
- add integration test verifying timeout behavior with slow backend
- add slowMockBackend that respects context cancellation
@lidel lidel self-assigned this Jan 9, 2026
@lidel lidel changed the title add configurable fallback timeout for the gateway handler feat(gateway): configurable fallback timeout for the gateway handler Jan 9, 2026
@lidel lidel merged commit 89dc184 into main Jan 9, 2026
23 of 24 checks passed
lidel added a commit to ipfs/kubo that referenced this pull request Jan 9, 2026
exposes the previously hardcoded 1 hour gateway request deadline as a
configurable option, allowing operators to adjust it to fit deployment
needs. protects gateway from edge cases and slow client attacks.

boxo: ipfs/boxo#1079
@lidel lidel deleted the config-gw-request-timeout branch January 9, 2026 23:36
lidel added a commit to ipfs/kubo that referenced this pull request Jan 15, 2026
* feat(config): add Gateway.MaxRequestDuration option

exposes the previously hardcoded 1 hour gateway request deadline as a
configurable option, allowing operators to adjust it to fit deployment
needs. protects gateway from edge cases and slow client attacks.

boxo: ipfs/boxo#1079

* test(gateway): add MaxRequestDuration integration test

verifies config is wired correctly and 504 is returned when exceeded

* docs: add MaxRequestDuration to gateway production guide

---------

Co-authored-by: Andrew Gillis <11790789+gammazero@users.noreply.github.com>
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.

3 participants