I am trying to setup Split IO to run in Localhost mode. I followed the documentation here, help.split.io
Here is my code for getting the split client,
import { SplitFactory } from '@splitsoftware/splitio';
import * as path from 'path';
const getServerSideSplitClient = async (): Promise<SplitIO.IClient> => {
const config = {
core: {
authorizationKey: 'localhost',
},
features: path.resolve(process.cwd(), 'split.yml'),
scheduler: {
offlineRefreshRate: 15, // 15 sec
},
debug: process.env.NODE_ENV === 'production' ? false : true,
};
console.log(config);
const splitFactory: SplitIO.ISDK = SplitFactory(config);
const client: SplitIO.IClient = splitFactory.client();
console.log('Created split client');
try {
console.log('This is in the try');
await client.ready().catch((e) => {
console.log(`This is your error: ${e}`);
throw e;
});
console.log('This is after ready');
} catch (e) {
console.log(`This is in the catch ${e}`);
throw new Error('Error initializing the split client.');
}
return client;
};
export default getServerSideSplitClient;
When I run the program, it logs the config with the correct path to my yaml file, "Created split client", "This is in the try", This is your error: Error: Split SDK emitted SDK_READY_TIMED_OUT event.
This is what I see in the terminal,
[WARN] splitio => settings: You already have 5 factory/ies with this API Key. We recommend keeping only one instance of the factory at all times (Singleton pattern) and reusing it throughout your application
[DEBUG] splitio => sync: Starting offlineUpdater. Running each 20000 millis
[DEBUG] splitio => sync: Running offlineUpdater
[ERROR] splitio => sync:offline: There was an issue loading the mock Splits data, no changes will be applied to the current cache. TypeError: Cannot read property 'treatment' of null
[INFO] splitio => New Split SDK instance created.
[DEBUG] splitio => Retrieving default SDK client.
Created split client
This is in the try
[DEBUG] splitio => sync: Running offlineUpdater
This is your error: Error: Split SDK emitted SDK_READY_TIMED_OUT event.
This is in the catch Error: Split SDK emitted SDK_READY_TIMED_OUT event.
It seems like the sdk never gets ready because it is timing out. My page never renders.