Conversation
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The adapter had no shutdown mechanism. close() now reverts it to its uninitialized state, so the next evaluation initializes it again, per section 2.5 of the OpenFeature provider spec. It first awaits an initialization that is still in flight, so the client that initialization produces is disposed rather than leaked, and it is idempotent. Provider disposal is opt-in through the new onClose option, because the adapter cannot do it on its own: an OpenFeature client has no close of its own, and shutting down providers means closing them on the global OpenFeature API, which would also affect providers this adapter never registered. Follow-up to #474, which fixed #473. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
dferber90
marked this pull request as draft
August 15, 2026 05:09
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.
Follow-up to #474, which corrected the initialization retry behavior and closed #473. This PR contains only the shutdown mechanism.
The condition
The adapter had no shutdown mechanism. Section 2.5 of the OpenFeature provider specification gives requirements for such a mechanism.
The new
close()functionclose()puts the adapter in its uninitialized state. The next evaluation initializes the adapter again. See requirement 2.5.2.close()first waits for the initialization. The client then goes toonClose, and the adapter does not leak the client. If an evaluation starts during the shutdown, the evaluation waits, then it initializes the adapter again. See requirement 2.5.2.close()is idempotent. Concurrent calls share one shutdown. A second call does nothing more, if no initialization occurred between the two calls. See requirement 2.5.3.close()then does not callonClose.Requirement 2.5.1 is about the disposal of resources. The new
onCloseoption does this, because the adapter cannot do it correctly:An OpenFeature client has no function to close itself. To shut down a provider, you must close the provider on the global
OpenFeatureAPI. But that also closes providers that this adapter did not register. Thus the user must give permission for the disposal.The new options parameter is an addition to both overloads. Existing code continues to operate.
Be careful: if you give a
Clientto the adapter, and not aninitfunction, the adapter has nothing to make again. Evaluations afterclose()then continue to use the same client. The README gives this information.Tests
There are 7 new tests for
close(). I also did mutation tests on the two most difficult lines: the guard for a shutdown in progress ininitialize(), and the wait for the initialization in progress. If you remove one of these two lines, one test fails.All 21 tests,
pnpm type-check,pnpm check, andpnpm buildare successful.Specification
https://openfeature.dev/specification/sections/providers#25-shutdown
🤖 Generated with Claude Code