fix the parsing error

Summary:
The headless version used to use `JSON.stringify` to serialize the output of `serializeStore` which basically transformed the store to a specific format which is serializable.  But we have written the custom serialize function which cateres to the non serializable object types. Headless didn't use it, so thats why it exported Flipper trace in an unrecognizable format for the flipper.

I have also renamed `serializeStore` to `prepareToSerializeStore` so that the confusion doesn't occur in future. I have used an `exportStore` function in headless which exports the store to the `Promise<String>`

Reviewed By: jknoxville

Differential Revision: D14480096

fbshipit-source-id: f312d7637aa082d96c3bc1dfd00eefb19182e97f
This commit is contained in:
Pritesh Nandgaonkar
2019-03-15 09:46:34 -07:00
committed by Facebook Github Bot
parent 2813b584f6
commit e184af7f2a
2 changed files with 6 additions and 6 deletions

View File

@@ -178,7 +178,7 @@ export const processStore = (
return null;
};
export async function serializeStore(store: Store): Promise<?ExportType> {
export async function getStoreExport(store: Store): Promise<?ExportType> {
const state = store.getState();
const {clients} = state.connections;
const {pluginStates} = state;
@@ -232,12 +232,12 @@ export async function serializeStore(store: Store): Promise<?ExportType> {
export function exportStore(store: Store): Promise<string> {
getLogger().track('usage', EXPORT_FLIPPER_TRACE_EVENT);
return new Promise(async (resolve, reject) => {
const json = await serializeStore(store);
if (!json) {
const storeExport = await getStoreExport(store);
if (!storeExport) {
console.error('Make sure a device is connected');
reject('No device is selected');
}
const serializedString = serialize(json);
const serializedString = serialize(storeExport);
if (serializedString.length <= 0) {
reject('Serialize function returned empty string');
}