Nit: this guard should be simplified to `if (getProviderState(provider))`.