Closed ghost closed 5 years ago
The intention was not to wait for the ready
event during every request, but just at startup time. By definition, using once
to listen for an event will only ever call the handler once, so it would never make sense to use once
in a request handler. We'll try to clarify the documentation.
The once ready in the documentation didn’t make sense in the request handler for me either.
However, it wasn’t documented on what to do in the request handler.
I update the documentation to clarify that the ready
event is only emitted once, and that production code shouldn't depend on using that.
In the docs, we are directed to create a client via
const ld_client = LaunchDarkly.init('SOME_KEY');
Then in our server's request handler, we are directed to this code:
However, our Node app would work the first time a request came through, but time out on the second request. Why? Because our app was waiting for the 'ready' event, and it never came. So, we went with the following, based on what we found in the source code:
and now our node server can handle requests again, and we can update our LaunchDarkly settings and see the variations.
My only issue to please update the documentation. Thank you!