Description
I see this error occuring in my logs quite a lot, I've somehow ended up with an empty file in my
C:\Users\ewan\.appcelerator\appcd\telemetry
dir, when trying to send the events appcd-telemetry chokes on this and fails to send. What we should do is wrap the JSON.parse in a try/catch if it throws nuke the file so we dont keep dying (the file on my machine is 2 days old)
2017-10-26T13:03:44.211Z error at JSON.parse (<anonymous>)
2017-10-26T13:03:44.211Z error at json.batch.map.file (C:\Users\ewan\Documents\git\appc-daemon\packages\appcd-telemetry\src\telemetry.js:251:20)
2017-10-26T13:03:44.211Z error at Array.map (<anonymous>)
2017-10-26T13:03:44.211Z error at pending.resolve (C:\Users\ewan\Documents\git\appc-daemon\packages\appcd-telemetry\src\telemetry.js:249:22)
2017-10-26T13:03:44.211Z error at new Promise (<anonymous>)
2017-10-26T13:03:44.211Z error at sendBatch (C:\Users\ewan\Documents\git\appc-daemon\packages\appcd-telemetry\src\telemetry.js:247:20)
2017-10-26T13:03:44.211Z error at Timeout.sendTimer.setTimeout [as _onTimeout] (C:\Users\ewan\Documents\git\appc-daemon\packages\appcd-telemetry\src\telemetry.js:285:4)
2017-10-26T13:03:44.211Z error at ontimeout (timers.js:471:11)
2017-10-26T13:03:44.211Z error at tryOnTimeout (timers.js:306:5)
2017-10-26T13:03:44.211Z error at Timer.listOnTimeout (timers.js:266:5) } SyntaxError: Unexpected end of JSON input
2017-10-26T13:03:44.211Z error at JSON.parse (<anonymous>)
2017-10-26T13:03:44.211Z error at json.batch.map.file (C:\Users\ewan\Documents\git\appc-daemon\packages\appcd-telemetry\src\telemetry.js:251:20)
2017-10-26T13:03:44.211Z error at Array.map (<anonymous>)
2017-10-26T13:03:44.211Z error at pending.resolve (C:\Users\ewan\Documents\git\appc-daemon\packages\appcd-telemetry\src\telemetry.js:249:22)
2017-10-26T13:03:44.211Z error at new Promise (<anonymous>)
2017-10-26T13:03:44.211Z error at sendBatch (C:\Users\ewan\Documents\git\appc-daemon\packages\appcd-telemetry\src\telemetry.js:247:20)
2017-10-26T13:03:44.211Z error at Timeout.sendTimer.setTimeout [as _onTimeout] (C:\Users\ewan\Documents\git\appc-daemon\packages\appcd-telemetry\src\telemetry.js:285:4)
2017-10-26T13:03:44.211Z error at ontimeout (timers.js:471:11)
2017-10-26T13:03:44.211Z error at tryOnTimeout (timers.js:306:5)
Steps to reproduce
Run touch ~/.appcelerator/appcd/telemetry/c9bc717a-eeb1-4740-81cc-db5525c25ac4.json
(might not work on Windows)
Watch the logs for events being sent
Actual
Chokes parsing a file
Expected
Should not choke and should remove file
https://github.com/appcelerator/appc-daemon/pull/98