fix: cancel in-flight initialize when context changes - #263
Open
fabriziodemaria wants to merge 2 commits into
Open
fix: cancel in-flight initialize when context changes#263fabriziodemaria wants to merge 2 commits into
fabriziodemaria wants to merge 2 commits into
Conversation
fabriziodemaria
requested review from
andreas-karlsson,
mfranberg,
nicklasl and
vahidlazio
as code owners
August 19, 2026 06:23
Member
|
closes #262 |
fabriziodemaria
changed the base branch from
openfeature-0.6-migration
to
main
August 19, 2026 06:27
OpenFeature 0.6 can start onContextSet before initialize's Future resolves. Route both through TaskManager so the latest context owns the cache and superseded calls do not emit stale status events. Co-authored-by: Cursor <cursoragent@cursor.com>
fabriziodemaria
force-pushed
the
fix/lifecycle-cancel-and-supersede
branch
from
August 19, 2026 06:28
0bb3857 to
a97c21d
Compare
Co-Authored-By: Codex <noreply@openai.com>
Member
|
Could we make committing the resolution conditional on the task still owning the current generation? I guess cancellation can land after the check but before |
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
initializeandonContextSetthrough the sameTaskManagergeneration so a later context change cancels in-flight init/prefetch instead of racing it..ready/.contextChanged/.staleonly if that call is still current; a superseded fetch cannot overwrite flags or status.fetchAndActivateinit,activateAndFetchAsyncprefetch, and stackedonContextSetcalls.Why not FIFO
OpenFeature 0.6 serializes lifecycle call starts, not Future completion. #261 queues the work so initialize always finishes first. This PR follows the SDK's existing cancel-and-supersede model (and OpenFeature's guidance) so the app does not wait on a resolve for a context it already replaced.
Stacked on #259.
Test plan
swift test --skip ConfidenceIntegrationTest --skip MixedTypesFlagIntegrationTestswiftlint lint --stricton touched filesMade with Cursor