service-worker-gateway icon indicating copy to clipboard operation
service-worker-gateway copied to clipboard

Implement Retrieval Timeout

Open lidel opened this issue 2 months ago • 1 comments

Service Worker should have a configurable Retrieval Timeout, set to 30s by default to match current UX of Kubo, Rainbow, ipfs.io / dweb.link:

Gateway.RetrievalTimeout at kubo/docs/config.md:

Timeout behavior:

  • Time to first byte: Returns 504 Gateway Timeout if the gateway cannot start writing within this duration (e.g., stuck searching for providers)
  • Time between writes: After first byte [block], timeout resets with each write [block]. Response terminates if no new data [block] can be written within this duration

Prior art GO code:

  • https://github.com/ipfs/kubo/pull/10905
    • https://github.com/ipfs/boxo/pull/994

lidel avatar Oct 23 '25 20:10 lidel

This is already partially implemented though it doesn't reset between blocks.

We probably don't need to go to the level of blocks specifically, we can just wrap the @helia/verified-fetch response body stream and reset a timer every time any chunk of data is sent to the caller.

achingbrain avatar Oct 24 '25 15:10 achingbrain