fix(resolve): share response headers with singleflight followers#1389
Merged
fix(resolve): share response headers with singleflight followers#1389
Conversation
Contributor
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughAdds leader-to-follower deduplication state propagation for single-flight requests: new context callbacks for typed get/set, storage of leader HTTP metadata (status and headers) on single-flight items, propagation of that metadata to follower contexts, and supporting tests. Also exposes a ResponseContext getter from the HTTP client package. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Resolver
participant Context as RequestContext
participant InflightMgr as Inflight Manager
participant HTTP as HTTP Client
Client->>Resolver: Resolve request (may be follower)
alt No existing inflight (Leader)
Resolver->>HTTP: Execute HTTP request
HTTP-->>Resolver: Response + ResponseContext
Resolver->>Context: Capture ResponseContext (status, headers)
Resolver->>InflightMgr: Store leader SharedData/status/headers
end
Note over Resolver,InflightMgr: Followers arriving while leader is active
alt Follower uses single-flight result
Client->>Resolver: Resolve (follower)
Resolver->>InflightMgr: Retrieve leader SharedData/status/headers
InflightMgr-->>Resolver: Return SharedData
Resolver->>Context: Inject SharedData via SetDeduplicationData
Resolver-->>Client: Return response using leader's HTTP metadata
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
266498a to
dc7a163
Compare
Subgraph singleflight followers now receive the leader's HTTP response headers and status code by storing them in SingleFlightItem and populating the follower's ResponseContext on the way out. Inbound request singleflight followers now support arbitrary shared data via two new opt-in callbacks on Context (GetDeduplicationData / SetDeduplicationData), enabling the cosmo router to propagate response header state from leader to follower. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
dc7a163 to
c28d5e1
Compare
…sertion - Clone responseHeaders for each singleflight follower to prevent data races when downstream code mutates headers concurrently - Use comma-ok type assertion in SetDeduplicationCallbacks instead of bare assertion that could panic on type mismatch - Add doc comment on GetResponseContext - Fix stale line-number reference, add ordering invariant documentation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
devsergiy
approved these changes
Feb 18, 2026
…timeout path Followers that timed out would write their context error to the shared request.Err field without synchronization, racing with other followers and the leader's FinishErr. Return ctx.Err() directly instead of mutating shared state. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5 tasks
jensneuse
pushed a commit
that referenced
this pull request
Feb 18, 2026
🤖 I have created a release *beep* *boop* --- ## [2.0.0-rc.251](v2.0.0-rc.250...v2.0.0-rc.251) (2026-02-18) ### Bug Fixes * **resolve:** share response headers with singleflight followers ([#1389](#1389)) ([ed80a8e](ed80a8e)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed an issue where response headers were not properly shared with singleflight followers. --- **Version:** 2.0.0-rc.251 <!-- end of auto-generated comment: release notes by coderabbit.ai -->
3 tasks
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by CodeRabbit
New Features
Tests
When singleflight deduplication is active, follower requests previously received only the serialized response body from the leader — subgraph response headers (e.g.
Cache-Control, custom propagated headers) were silently dropped.This fix addresses both singleflight mechanisms:
SingleFlightItemnow carriesresponseHeadersandstatusCodefrom the leader's HTTP call. Followers populate theirResponseContextfrom these fields, soLoaderHooks.OnFinishedreceives the correctResponseInfo.ResponseHeadersfor every request.GetDeduplicationData/SetDeduplicationData) onContextallow the cosmo router to extract arbitrary state (e.g. accumulated response headers) from the leader and apply it to each follower before writing the response.Checklist