kusold / todoist-habitrpg

One way sync from Todoist -> HabitRPG
120 stars 14 forks source link

Cannot Read Property 'type' of Undefined #44

Open LaikeSF opened 8 years ago

LaikeSF commented 8 years ago

The latest build of the script is throwing an error. Any idea on what's going on?

Edit: Seems like I accidentally ticked a repeating monthly task off in Habitica. Deleting that task in Todoist and remaking it solved the problem.

/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 Object._onImmediate (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/async/lib/async.js:554:34)
    at processImmediate [as _immediateCallback] (timers.js:330:15)
kusold commented 8 years ago

Odd that res.body is undefined. I'll dig into this. It's probably an issue with https://github.com/kusold/habitrpg-api/blob/master/lib/apiv3.js#L190 but I'll make sure.

If you can provide any info about the task that you were trying to sync, that'd help me cut debugging time down.

LaikeSF commented 8 years ago

As I just posted in my edit:

Seems like I accidentally ticked a repeating monthly task off in Habitica. The missing monthly task was the cause of the error. Deleting that task in Todoist and remaking it solved the problem.

kusold commented 8 years ago

Ah. I must have missed HabitRPG adding repeating monthlies. That shouldn't be too hard to support.

LaikeSF commented 8 years ago

The repeating monthly is on the Todoist side. It creates a regular task that just shifts the task's to do date on HabitRPG every time it is completed on Todoist.

ajfclark commented 8 years ago

I'm also getting this error after mistakenly ticking off a few things in Habitica:

/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)

Is there any way to track down the task that needs to be recreated in todoist?

cygnoir commented 8 years ago

I'm getting the same error after clearing out old tasks in Habitica and Todoist. Now I have zero "monthlies" and a few dailies, but I still get this error.

/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.<anonymous> (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/async/lib/async.js:554:34)
    at runCallback (timers.js:574:20)
    at tryOnImmediate (timers.js:554:5)
    at processImmediate [as _immediateCallback] (timers.js:533:5)
JoshBoehm commented 8 years ago

+1 for this error. Was working fine for me yesterday and now I get it every time I run the sync.

/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)

rayvdz commented 8 years ago

Same here... I just set it up and was doing some testing. Just standard tasks. Ticked a few off in habitica then tried to add a few more then got this error...

/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.<anonymous> (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/async/lib/async.js:554:34)'
    at runCallback (timers.js:637:20)
    at tryOnImmediate (timers.js:610:5)
    at processImmediate [as _immediateCallback] (timers.js:582:5)

BTW, these are tasks I have put into a specific board on Trello, then used IFTTT to copy them to Todoist. Only really using todoist as a way to get tasks into Habitica.

Was testing this out, looking eventually to be running this script on my Synology Server as a cron job.

kusold commented 8 years ago

I published 1.0.1. It includes a stop gap that should prevent crashing. It may prevent dailies from being set properly, but until I need some information before I can create a test case for this.

If people could upgrade to 1.0.1, run it, then post the corresponding error message (should look like: ERROR: Body is undefined. Please file an issue with this. res:) then I can get this fixed for real.

rayvdz commented 8 years ago

BTW, clearing the JSON file fixed the problem for me. But luckily i only had a few tasks to play with (I deleted all my tasks on habitica). I will let you know any errors should they come up.

My mistake I think was that I checked off tasks directly in Habitica. It was not clear when I started using this script that i had to check off the tasks in todoist.

What I actually wanted was to be able to sync only 'today's' tasks onto Habitica. That way I could use just one tool for today's tasks... ideally checking them off in habitica. But I realise that this is not how this script is intended to be used.

LaikeSF commented 8 years ago

I've updated to the new script and it is now throwing up the following error /usr/local/lib/node_modules/todoist-habitrpg/habitSync.js:222 OR: Body is undefined. Please file an issue with this. res:' + JSON.stringify( ^ TypeError: Converting circular structure to JSON at Object.stringify (native) at /usr/local/lib/node_modules/todoist-habitrpg/habitSync.js:222:97 at fn (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/async/lib/async.js:638:34) at Object._onImmediate (/usr/local/lib/node_modules/todoist-habitrpg/node_modules/async/lib/async.js:554:34) at processImmediate [as _immediateCallback] (timers.js:330:15)

kusold commented 8 years ago

That's a doozy... I switched out the JSON.Stringify with a util.inspect which should handle that. It's published in v1.1.1. Could you please update and re-run? Hopefully it will let me hone in on this bug and why it might be happening.

LaikeSF commented 8 years ago

I've uploaded the new update and it seems to be working ok so far.