Skip to content

fix: Prevent an FDv2 initializer result from being applied after close - #583

Merged
keelerm84 merged 1 commit into
mainfrom
mk/SDK-3591/interrupt-initializer
Nov 18, 2026
Merged

keelerm84 merged 1 commit into
mainfrom
mk/SDK-3591/interrupt-initializer

Conversation

@keelerm84

@keelerm84 keelerm84 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

When the client closed while an FDv2 initializer was still fetching, the data system kept going after close. It applied the initializer's result when the fetch returned, started the synchronizers, and logged the failed request as a warning or an exception.

Now close stops the initializer in progress. A result that arrives after close is not applied, and the synchronizers do not start. A polling result or error that arrives after close is not reported, and the error logs at debug.

Initializer gets a stop() method with a default implementation that does nothing. A custom initializer can implement it to end its fetch early. Close calls stop() only if the initializer has one, so an initializer that matches the protocol without the method still works.

A polling request in progress still runs until it completes or times out, so close can still wait up to 5 seconds for it.


Note

Overview
Closing the client while an FDv2 initializer is still in fetch() no longer applies its result or starts synchronizers. FDv2.stop() sets the stop event, optionally calls Initializer.stop() when present (tracked as _active_initializer under the write lock), and the main loop bails out if shutdown happened during initialization.

The Initializer protocol gains an optional stop() with a no-op default so custom sources can unblock fetch(); shutdown uses getattr so duck-typed initializers without stop still work.

PollingDataSourceV2 ignores poll results that finish after stop() (sync loop breaks instead of yielding) and logs fetch/poll failures at debug during shutdown instead of warning/exception.

Reviewed by Cursor Bugbot for commit f9b090a. Bugbot is set up for automated code reviews on this repo. Configure here.

@keelerm84
keelerm84 requested a review from a team as a code owner November 13, 2026 21:32
@cursor cursor Bot added the risk:medium label Nov 13, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Risk: medium.

Automated risk review (dry run): Medium

This PR would not be automatically approved. Human approval required.

Why: This changes FDv2 shutdown and in-flight initializer handling in ldclient/impl/datasystem/fdv2.py and ldclient/interfaces.py, plus polling after-close logging. Tests cover the new close path, but concurrent SDK lifecycle behavior is above Low.

Human review is needed, and no reviewers were assigned.

If you disagree with this review, share this PR in #feedback-agent-approvals or submit a changes-requested review explaining why.

Open in Web View Automation 

Sent by Cursor Approval Agent: Dry-Run PR Approver

@keelerm84
keelerm84 merged commit 85e948c into main Nov 18, 2026
19 checks passed
@keelerm84
keelerm84 deleted the mk/SDK-3591/interrupt-initializer branch November 18, 2026 15:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants