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

Cannot Read Property 'type' of Undefined #44

Open
LaikeSF opened this issue Aug 15, 2016 · 13 comments
Open

Cannot Read Property 'type' of Undefined #44

LaikeSF opened this issue Aug 15, 2016 · 13 comments

Comments

@LaikeSF
Copy link

LaikeSF commented Aug 15, 2016

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

kusold commented Aug 15, 2016

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

LaikeSF commented Aug 15, 2016

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

kusold commented Aug 15, 2016

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

@LaikeSF
Copy link
Author

LaikeSF commented Aug 16, 2016

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

ajfclark commented Sep 4, 2016

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

cygnoir commented Sep 9, 2016

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

JoshBoehm commented Sep 23, 2016

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

rayvdz commented Oct 31, 2016

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

kusold commented Nov 2, 2016

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

rayvdz commented Nov 2, 2016

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

LaikeSF commented Nov 9, 2016

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

kusold commented Nov 9, 2016

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

LaikeSF commented Nov 12, 2016

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

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

6 participants