Wait for server initialization
You can manually trigger and wait for server initialization with the initIfNeeded
method:
When using initIfNeeded
, the initDataRefreshIntervalMs
option specifies the minimum time between initialization requests.
For example, if you set this to 5_000
, initIfNeeded
will only trigger a new initialization request if the last one was over 5 seconds ago.
So you can await initIfNeeded
on every backend request to ensure flag values are fresh while minimizing network latency and bandwidth.
This is particularly useful in serverless and edge environments like Vercel deployments, Cloudflare Workers, AWS Lambdas, etc, where background SDK tasks like fetching updates aren't guaranteed to execute.
Check for server initialization
You can also check for server initialization with the getLastInitDataRefreshTime
method:
Last updated