refactor(mothership): add try/catch + debugging

This commit is contained in:
Alexis Tyler
2020-05-08 10:15:57 +09:30
parent a4d00e2480
commit b174c362a4
+12 -6
View File
@@ -283,12 +283,18 @@ const connectToMothership = async (currentRetryAttempt: number = 0) => {
return;
}
mothership.send(JSON.stringify({
type: 'data',
payload: {
data: JSON.parse(response.body).data
}
}));
try {
const data = JSON.parse(response.body).data;
const payload = { data };
log.debug('Sending payload to mothership', payload);
mothership.send(JSON.stringify({
type: 'data',
payload
}));
} catch (error) {
log.error(error);
mothership.close();
}
});
}
} catch (error) {