This topic explains how to safely shut down different LaunchDarkly SDKs. This feature is available for client-side, server-side, and edge SDKs.
LaunchDarkly SDKs provide language-specific methods to shut down their instances safely.
In most applications, you do not have to manually shut down an SDK. LaunchDarkly SDKs automatically flush pending analytics events to LaunchDarkly at regular intervals.
However, when your application is about to terminate, you should shut down the LaunchDarkly client. For most SDKs, this ensures that the client releases any resources it is using, and that it delivers any pending analytics to LaunchDarkly. If your application terminates without this shutdown step, flag evaluations and contexts or users may not appear on the Contexts list, because they are derived from analytics events. To learn more, read Analytics events.
Do not attempt to evaluate flags or otherwise use the LaunchDarkly client after it has shut down, as doing so may result in undefined behavior. Shut down the client at a point in your application’s lifecycle where the client is no longer needed.
Details about each SDK’s configuration are available in the SDK-specific sections below.
This feature is available in the following client-side SDKs:
To shut down:
To shut down:
In the C++ SDK v3.0, the client will be automatically closed.
If you are using the C binding, you must specifically close the client. The operation blocks until all resources are free.
To shut down:
To shut down:
To shut down:
To shut down:
To shut down:
Calling close flushes all queued events and shuts all open network connections.
To shut down:
To learn more, read close.
This feature is available in the following server-side SDKs:
In the C++ SDK v3.0, the SDK will be automatically closed.
If you are using the C binding, you must specifically close the client. The operation blocks until all resources are free.
To shut down:
stop_instance(), stop_instance(Tag), and stop_all_instances() all safely shut down client instances and release the resources associated with them.
To shut down:
To shut down:
Close safely shuts down the client instance and releases all resources associated with the client.
To shut down:
Unlike other LaunchDarkly SDKs, the Node.js (server-side) SDK does not automatically send pending analytics events to LaunchDarkly when it shuts down. To send analytics events, you first need to call flush.
To shut down:
To shut down:
Shutting down frees the resources the worker threads were using and provides an explicit signal for the Ruby SDK to send the remaining event data back to LaunchDarkly.
To shut down:
To shut down:
This feature is available in the following edge SDKs:
close safely shuts down the client instance:
close safely shuts down the client instance: