todoist-habitrpg icon indicating copy to clipboard operation
todoist-habitrpg copied to clipboard

TypeError: Cannot read property 'body' of undefined in apiv3.js

Open ajfclark opened this issue 8 years ago • 7 comments

Last night my cron job failed with:

/usr/local/lib/node_modules/todoist-habitrpg/node_modules/habitrpg-api/lib/apiv3.js:189
  if(apiVersion === 'v2' && res.body) {
                               ^

TypeError: Cannot read property 'body' of undefined
    at formatResponse (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/habitrpg-api/lib/apiv3.js:189:32)
    at /usr/local/lib/node_modules/todoist-habitrpg/node_modules/habitrpg-api/lib/apiv3.js:61:7
    at Request.callback (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/habitrpg-api/node_modules/superagent/lib/node/index.js:660:30)
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/habitrpg-api/node_modules/superagent/lib/node/index.js:628:10)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at TLSSocket.socketErrorListener (_http_client.js:256:9)
    at emitOne (events.js:77:13)
    at TLSSocket.emit (events.js:169:7)
    at connectErrorNT (net.js:997:8)

Trying to rerun the sync fails with:

/usr/local/lib/node_modules/todoist-habitrpg/habitSync.js:218
        if(res.body.type == "daily") {
                   ^

TypeError: Cannot read property 'type' of undefined
    at /usr/local/lib/node_modules/todoist-habitrpg/habitSync.js:218:20
    at fn (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/async/lib/async.js:638:34)
    at Immediate._onImmediate (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/async/lib/async.js:554:34)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

Previous syncs have worked fine.

ajfclark avatar Sep 15 '16 20:09 ajfclark

This cropped up again when I renamed a label in todoist trying to get the attributes to sync across correctly.

ajfclark avatar Sep 24 '16 22:09 ajfclark

It's a persistent issue for me, too, especially if I accidentally complete a task in habitica without completing it in todoist. Unfortunately, tracking down the exact wrong information in the .json is a pain and a fucking half.

eringiglio avatar Sep 26 '16 15:09 eringiglio

Hey, @ajfclark , how did you fix it? I have found that deleting my entire .json works, but then I have to go through and manually delete all the newly duplicated todoist tasks when I resync it and that suuuuuucks. Is there a better way?

eringiglio avatar Sep 26 '16 18:09 eringiglio

I haven't found one sorry @eringiglio

I delete the stuff in habitica first and then the json and resync. That way I can just clear everything in habitica rather than trying to figure out which duplicates to delete. Still very tedious.

ajfclark avatar Oct 23 '16 21:10 ajfclark

Once again, this has cropped up. Every sync attempt dies with:

/usr/local/lib/node_modules/todoist-habitrpg/node_modules/habitrpg-api/lib/apiv3.js:189
  if(apiVersion === 'v2' && res.body) {
                               ^

TypeError: Cannot read property 'body' of undefined
    at formatResponse (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/habitrpg-api/lib/apiv3.js:189:32)
    at /usr/local/lib/node_modules/todoist-habitrpg/node_modules/habitrpg-api/lib/apiv3.js:61:7
    at Request.callback (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/habitrpg-api/node_modules/superagent/lib/node/index.js:660:30)
    at ClientRequest.<anonymous> (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/habitrpg-api/node_modules/superagent/lib/node/index.js:628:10)
    at emitOne (events.js:77:13)
    at ClientRequest.emit (events.js:169:7)
    at TLSSocket.socketErrorListener (_http_client.js:269:9)
    at emitOne (events.js:77:13)
    at TLSSocket.emit (events.js:169:7)
    at emitErrorNT (net.js:1269:8)

I've deleted every task from Habitica but no joy, it still crashes. I've deleted the JSON file and it still crashes. My sync is currently completely broken and doesn't work at all.

This is incredibly frustrating. Can we please get some adequate debugging around this error so we can see which task is causing the problem? Even if it was just a debug mode that output every task to the console as it was syncing so we could try and narrow down where the issue is?

ajfclark avatar Jan 25 '17 01:01 ajfclark

Yes, I'm having the same issue. In the past, this popped up when I'd checked something off in Habitica that hadn't been checked off in Todoist, but I don't think I did that today.

diyadas avatar Jan 25 '17 05:01 diyadas

Appears the sync is completely broken at the moment. Even with nothing in habitica and no JSON it doesn't work any more. I guess it wouldn't work for a new user either then.

ajfclark avatar Jan 25 '17 12:01 ajfclark