Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localMode regression in 5.5.0 #28

Open
michaeltnguyen opened this issue May 17, 2023 · 3 comments
Open

localMode regression in 5.5.0 #28

michaeltnguyen opened this issue May 17, 2023 · 3 comments

Comments

@michaeltnguyen
Copy link

Calling statsig.initialize with localMode: true emits the following warning to the console:

StatsigLocalModeNetworkError: No network requests in localMode
    at new StatsigLocalModeNetworkError (/node_modules/statsig-node/dist/Errors.js:52:28)
    at StatsigFetcher.post (/node_modules/statsig-node/dist/utils/StatsigFetcher.js:29:35)
    at SpecStore.<anonymous> (/node_modules/statsig-node/dist/SpecStore.js:643:59)
    at step (/node_modules/statsig-node/dist/SpecStore.js:33:23)
    at Object.next (/node_modules/statsig-node/dist/SpecStore.js:14:53)
    at /node_modules/statsig-node/dist/SpecStore.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/node_modules/statsig-node/dist/SpecStore.js:4:12)
    at SpecStore.syncIdListsFromNetwork (/node_modules/statsig-node/dist/SpecStore.js:631:16)
    at SpecStore.<anonymous> (/node_modules/statsig-node/dist/SpecStore.js:217:55)

This can be reproduced with a one-liner:

statsig.initialize('secret-', { localMode: true });

The apis that statsig-node are trying to hit are:

This happens in 5.5.0 but not in 5.4.2 (the previous version).

@tore-statsig
Copy link
Contributor

I think thats actually local mode working as intended, the only difference is now it prints to the console (this same error was thrown previously, just not printed)

cc @jacob-statsig

@michaeltnguyen
Copy link
Author

Hi @tore-statsig , thanks for the response.

We are using localMode: true for unit tests, and that error is being printed for every single test. It's very noisy.

I think the intent of StatsigLocalModeNetworkError is to catch errors in my code. For example, if I'm attempting to make a checkGate call that hasn't been properly mocked / stubbed / overridden, it is a warning to fix my code.

I don't think this error should be thrown in the initialize call. Ideally, initialize would check the localMode flag and avoid calling download_config_specs and get_id_lists.

@jacob-statsig
Copy link
Contributor

jacob-statsig commented May 18, 2023

@michaeltnguyen Thanks for pointing this out. We will be replacing this error logging with a no-op on network requests when in localMode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants