Skip to content

[pull] canary from vercel:canary#1046

Merged
pull[bot] merged 1 commit into
code:canaryfrom
vercel:canary
May 14, 2026
Merged

[pull] canary from vercel:canary#1046
pull[bot] merged 1 commit into
code:canaryfrom
vercel:canary

Conversation

@pull

@pull pull Bot commented May 14, 2026

Copy link
Copy Markdown

See Commits and Changes for more details.


Created by pull[bot] (v2.0.0-alpha.4)

Can you help keep this open source service alive? 💖 Please sponsor : )

…#91729) (#93228)

## Summary

This is a re-application of the HTTP fetch part of #91729. Stacked on
#93227.

### Fix fetch to respect HTTP `Cache-Control` headers

Previously, `fetch` results were cached indefinitely, meaning results
would never be refreshed (unless the cache was invalidated). Now they
are `session_dependent` with a TTL to ensure we respect HTTP cache
settings (e.g. Google Fonts with `max-age=86400`).

New two-task pattern:
- **`fetch_inner`** (NOT `session_dependent`): Performs the HTTP
request, grabs an `Invalidator` for itself, and returns the response +
invalidator + absolute deadline. Cached across sessions.
- **`fetch`** (`network`, `session_dependent`): Reads the cached
`fetch_inner` result and spawns a timer to invalidate when the TTL
expires.

On warm cache restore, `fetch` re-executes (session-dependent), reads
the persisted deadline from `fetch_inner`'s cached result, computes
remaining TTL, and spawns a timer — no HTTP request unless the TTL has
already expired. Mid-session, the timer fires and triggers a re-fetch.

Error handling: On fetch failure, `fetch_inner` takes a dependency on
`Completion::session_dependent()` so transient errors (network down, DNS
failure) are retried on the next session without busy-looping.

## Test Plan

3 new integration tests in `turbo-tasks-fetch/tests/fetch.rs`:
- `ttl_invalidates_within_session` — mock server returns `max-age=1`,
body changes, verifies re-fetch after TTL
- `ttl_invalidates_on_session_restore` — fetches with TTL, stops TT,
waits for expiry, warm restores with new TT, verifies re-fetch
- `errors_retried_on_session_restore` — server returns 500, stops TT,
fixes server, warm restores, verifies success
- Existing 6 fetch tests continue to pass



<!-- NEXT_JS_LLM_PR -->
@pull pull Bot locked and limited conversation to collaborators May 14, 2026
@pull pull Bot added the ⤵️ pull label May 14, 2026
@pull pull Bot merged commit 2e90936 into code:canary May 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant