statsig-io / node-js-server-sdk

Statsig's SDK for server-side Node.js applications.
ISC License
21 stars 14 forks source link

How to properly handle initialization timeouts and errors? #24

Closed jefersondaniel closed 1 year ago

jefersondaniel commented 1 year ago

I was testing the initTimeoutMs option and noticed that the timeout behavior of the application is to enter an empty state and return false for every flags. However I would like to know when the FF failed so I do another behavior, like logging or returning an error.

What is the recommended practice here?

kenny-statsig commented 1 year ago

We don't support a callback specifically for initialize timeouts. But there is a rulesUpdatedCallback option which is triggered after successfully populating the store. If this callback is not triggered after initTimeoutMs elapsed, then I suppose you could treat it as a timeout.

bgmort commented 1 month ago

@kenny-statsig is there a reason there is no callback or other way to explicitly handle an initialization timeout? It would definitely be helpful for logging/troubleshooting purposes, and there would be less chance of developer errors or weird timing issues if the library provider the handler rather than us doing our own setTimeout check.