()
| 985 | * Reset GrowthBook client state (primarily for testing) |
| 986 | */ |
| 987 | export function resetGrowthBook(): void { |
| 988 | stopPeriodicGrowthBookRefresh() |
| 989 | // Remove process handlers before destroying client to prevent accumulation |
| 990 | if (currentBeforeExitHandler) { |
| 991 | process.off('beforeExit', currentBeforeExitHandler) |
| 992 | currentBeforeExitHandler = null |
| 993 | } |
| 994 | if (currentExitHandler) { |
| 995 | process.off('exit', currentExitHandler) |
| 996 | currentExitHandler = null |
| 997 | } |
| 998 | client?.destroy() |
| 999 | client = null |
| 1000 | clientCreatedWithAuth = false |
| 1001 | reinitializingPromise = null |
| 1002 | experimentDataByFeature.clear() |
| 1003 | pendingExposures.clear() |
| 1004 | loggedExposures.clear() |
| 1005 | remoteEvalFeatureValues.clear() |
| 1006 | getGrowthBookClient.cache?.clear?.() |
| 1007 | initializeGrowthBook.cache?.clear?.() |
| 1008 | envOverrides = null |
| 1009 | envOverridesParsed = false |
| 1010 | } |
| 1011 | |
| 1012 | // Periodic refresh interval (matches Statsig's 6-hour interval) |
| 1013 | const GROWTHBOOK_REFRESH_INTERVAL_MS = |
no test coverage detected