Skip to content
This repository has been archived by the owner on Mar 18, 2023. It is now read-only.

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

Open
ajfclark opened this issue Sep 15, 2016 · 7 comments
Open

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

ajfclark opened this issue Sep 15, 2016 · 7 comments

Comments

@ajfclark
Copy link

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
Copy link
Author

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

@eringiglio
Copy link

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
Copy link

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?

@ajfclark
Copy link
Author

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
Copy link
Author

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?

@diyadas
Copy link

diyadas commented Jan 25, 2017

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.

@ajfclark
Copy link
Author

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants