Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'length' of undefined #26

Open
boehser-enkel opened this issue Oct 1, 2020 · 24 comments
Open

Cannot read property 'length' of undefined #26

boehser-enkel opened this issue Oct 1, 2020 · 24 comments

Comments

@boehser-enkel
Copy link

Hi,

just updated to the neweset Homebridge Version. Now i get this error every night and my HB crashes:
[01/10/2020, 01:22:29] TypeError: Cannot read property 'length' of undefined at Component.getAllSubcomponents (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical.js/build/ical.js:2304:48) at new IcalExpander (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:17:34) at CalendarPoller._refreshCalendar (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:69:26) at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:54:14) at IncomingMessage.emit (events.js:327:22) at endReadableNT (_stream_readable.js:1201:12) at processTicksAndRejections (internal/process/task_queues.js:84:21) [01/10/2020, 01:22:29] Got SIGTERM, shutting down Homebridge... [01/10/2020, 01:22:34] [Deconz] goodbye

@appliko
Copy link

appliko commented Mar 15, 2021

I got same error every one/two days

at endReadableNT (_stream_readable.js:1139:12)
at processTicksAndRejections (internal/process/task_queues.js:81:17)
[3/14/2021, 10:48:32 PM] TypeError: Cannot read property 'length' of undefined
at Component.getAllSubcomponents (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical.js/build/ical.js:2304:48)
at new IcalExpander (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:17:34)
at CalendarPoller._refreshCalendar (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:69:26)
at IncomingMessage.resp.on (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:54:14)
at IncomingMessage.emit (events.js:198:15)
at endReadableNT (_stream_readable.js:1139:12)
at processTicksAndRejections (internal/process/task_queues.js:81:17)

@mrrivest
Copy link

mrrivest commented Feb 1, 2022

Same. Any solution?

TypeError: Cannot read properties of undefined (reading 'length')
at Component.getAllSubcomponents (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical.js/build/ical.js:2304:48)
at new IcalExpander (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:17:34)
at CalendarPoller._refreshCalendar (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:69:26)
at IncomingMessage. (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:54:14)
at IncomingMessage.emit (node:events:402:35)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

@elvirusDE
Copy link

Same problem since a couple of days now. It used to work without any problem and then without changes to the config this problem came up.
Any ideas what to do?

TypeError: Cannot read properties of undefined (reading 'length')
at Component.getAllSubcomponents (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical.js/build/ical.js:2304:48)
at new IcalExpander (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:17:34)
at CalendarPoller._refreshCalendar (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:69:26)
at IncomingMessage. (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:54:14)
at IncomingMessage.emit (node:events:402:35)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

My config:
"platform": "Calendar",
"name": "Calendar",
"calendars": [
{
"name": "Dienste Elvir",
"url": "webcal://p40-caldav.icloud.com/published/XXXXXXX",
"pollingInterval": 1,
"offset": "6m",
"sensors": [
"sensor1",
"sensor2",
"sensor3",
"sensor4"
]
}

@xTrackstar04x
Copy link

Just had the same error that started on 3/1/2022

[02/03/2022, 06:54:37] TypeError: Cannot read properties of undefined (reading 'length') at Component.getAllSubcomponents (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical.js/build/ical.js:2304:48) `at new IcalExpander (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:17:34)
at CalendarPoller._refreshCalendar (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:69:26)
at IncomingMessage. (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:54:14)
at IncomingMessage.emit (node:events:532:35)
at endReadableNT (node:internal/streams/readable:1346:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

@VoWiOx
Copy link

VoWiOx commented Mar 6, 2022

Same problem until 1st March 2022. Somebody have a tip to fix the issue?

Calendar was also iCloud.com. webcal://p55-caldav.icloud.com/published/2/xxxxxxxxxxxxx
Update to node.js 16.14 doesn't help.

[06/03/2022, 16:55:31] TypeError: Cannot read property 'length' of undefined
at Component.getAllSubcomponents (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical.js/build/ical.js:2304:48)
at new IcalExpander (/usr/local/lib/node_modules/homebridge-calendar/node_modules/ical-expander/index.js:17:34)
at CalendarPoller._refreshCalendar (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:69:26)
at IncomingMessage. (/usr/local/lib/node_modules/homebridge-calendar/src/CalendarPoller.js:54:14)
at IncomingMessage.emit (events.js:387:35)
at endReadableNT (internal/streams/readable.js:1317:12)
at processTicksAndRejections (internal/process/task_queues.js:82:21)

@elvirusDE
Copy link

elvirusDE commented Mar 8, 2022

Does anyone have an idea why this is happening now? Is it on the side of the calendar plugin or did Apple change something in their calendars recently? Can anybody help? Devs maybe?
I build a dedicated hardware to visualize certain calendar events and now the whole thing does not work. There is no other plugin available to do the job so I guess I vendor-locked myself into this situation. So please, I'm begging you, kind developers, would you please take a look into this issue? Please please.

@elvirusDE
Copy link

Hey guys,

@boehser-enkel, @appliko, @VoWiOx, @xTrackstar04x

What kind of ical-appointments are you using? I am using full-day events without start and end time. I am just curious and want to figure out what the problem might be.

I forked this repository and if no dev comes back to our issue then I will try to fix it for me. Maybe it will work for you too, so please be so kind and answer my question.

CU

@VoWiOx
Copy link

VoWiOx commented Mar 9, 2022

Hi @elvirusDE,
I am using also full-day events and weekly events (Monday-Friday full-day) for Home-Office work.
I also looking for alternatives and doesn‘t find another homebridge plugin for this function.
Now I using personal shortcuts to set dummy switches (homebridge plugin) on or off in homekit. With these dummy switches I control my homekit accessories. I started it once a day automatically at 1:00 am to read the todays calendar events.
For me it is working workaround.

I would prefer the homebridge calendar plugin when it was fixed.

Maybe the error is in ical.js module but I am not a developer in js.

Thanks in advance!

@elvirusDE
Copy link

elvirusDE commented Mar 20, 2022

Hey guys,

Because the developers did not post any answer to this issue or even posted any message, I forked the repository and wanted to try and test if the error still exist with updated dependencies. I wanted to try and test different solutions. I published my fork as a new plugin. And as soon as I started my Raspberry, the plugin started working again! The error is currently not present anymore in my system.

What about you guys? Is it working again for you too? Please tell me.

I will keep an eye on this issue and come back if the error returns for some reason. But currently I am happy that it is working again.

Cheers,
elvirus

@xTrackstar04x
Copy link

@elvirusDE I will try it right now. Would you be able to share how to install your fork? I've only installed plug ins for Homebridge via the UI

@elvirusDE
Copy link

@xTrackstar04x I am so sorry, the original plugin worked for me yesterday but today it stopped working again. I was so excited because I thought the error disappeared on its own. That's so bad.
I will work on my fork now. It will be installable publicly. Let me try to fix this issue and then I will tell you how to install it when its working.
Sorry for the misunderstanding.

CU

@elvirusDE
Copy link

@boehser-enkel, @appliko, @VoWiOx, @xTrackstar04x

Hi guys,

so I spent a day and a night on that issue and I have some findings:

First of all, you can install my fork if you wish by searching for the plugin name "homebridge-calendar-tempfix". I have just changed a little bit of code and I will tell you more details about it in the following.

First things first.

  • The plugin does not contain a real bug. The code is clean enough and does work as expected.
  • Since I have an Apple public icloud calendar to which my homebridge is connected, my problem has something to do with this setup and I want to share my findings.
  • Currently, my calendar is working in homebridge again
  • I found out that you are not allowed to poll the icloud calendar too often. I set up a pollingInterval of 2 and later 1 minute (because why not) and this causes the response of icloud to be empty. You can check this in your browser if you paste the public url into the address bar. You will get a ical file if everything is working and if you did poll your calendar too often you will get a blank page.
  • Unfortunately, the plugin is not able to handle a blank response. It will crash and lead to a restart of homebridge. Because the origin of the mistake is not gone you will end up in an endless loop of restarting homebridge again and again. And this is what I have changed. In my version you will get a log entry saying that the ical response for your calendar was empty and it will schedule the next calendar for the configured time interval. So your homebridge will not restart.
  • But you will get an empty response forever until you decrease the pollingInterval for your calendar. 5 minutes seems to be working fine for now. I will have to check that in the next days.

I made a pull request for the plugin to merge my changes because I think it adds to the stability and is really necessary but I don't think the devs are actively working on this plugin anymore.

Ok, that's all for now. CU :)

@xTrackstar04x
Copy link

@elvirusDE Just installed it. Looks like it is working for me!

@elvirusDE
Copy link

👍

@Thilos123
Copy link

Hej @elvirusDE. I Just tried you branch and still getting this error:

TypeError: Cannot read properties of undefined (reading 'forEach')
at CalendarPlatform.accessories (/homebridge/node_modules/homebridge-calendar-tempfix/src/index.js:39:15)
at /usr/local/lib/node_modules/homebridge/src/bridgeService.ts:534:24
at new Promise ()
at BridgeService.loadPlatformAccessories (/usr/local/lib/node_modules/homebridge/src/bridgeService.ts:528:12)
at /usr/local/lib/node_modules/homebridge/src/server.ts:447:42
at Array.forEach ()
at Server.loadPlatforms (/usr/local/lib/node_modules/homebridge/src/server.ts:374:27)
at Server.start (/usr/local/lib/node_modules/homebridge/src/server.ts:161:29)

Any ideas?

The .ics is just fine and downloading fine.

@elvirusDE
Copy link

Hi @Thilos123!

I have no idea, what is going wrong here. I will take a look at the code and try to figure out what might be the issue.
Please be so kind and describe your calendar data as detailed as possible. So that I have an idea of what you are trying to do...

Please keep in mind that I am not the original developer of that plugin so I am not deeply familiar with it. But fontunately it is not too complex so I will give it a try.

Cheers,
elvirus

@Thilos123
Copy link

Hey @elvirusDE. Thanks for the fast reply!
I have this .ics file - https://outlook.office365.com/owa/calendar/[email protected]/f33f2562e8c94130bb2159d216b8231e2088673443334102250/calendar.ics

I have tested with M365 calendar before that worked perfectly.

It's just a test calender containering a few events in the future.

The pictures below is what the console says and the config file.
image
image

@Thilos123
Copy link

Thilos123 commented Jun 14, 2022

Hello @elvirusDE . Just to give you some logs etc.
I have tried to change it up a bit from the config that was running. And now I get a different error code. hopefully the logs can help you.

image
image

Just started a new VM up with homebridge. This gives a ParserError.
image
image

@elvirusDE
Copy link

Thank you for the info. I will give it a try.
Please be patient as I don't have the time to work full time on this stuff.
I will keep you updated.

@Thilos123
Copy link

That is totally fair! :-) Thanks for looking into it.

I have actually got an cloud calender working now with this config:
{
"platform": "Calendar",
"calendars": [
{
"name": "apple",
"url": "webcal://pxxxxx",
"pollingInterval": 5
}
]
}

Can't get a Google or M365 to work still. But it seems they both uses HTTPS.
If i try to make it http, it says its needs to be https.

So it seems the common denominator is ics from https.

@elvirusDE
Copy link

Hi @Thilos123,

it seems that office365 calendars are not supported. In the readme of the library is stated that Apple (iCloud) calendars and Google calendars are supported. I am using an Apple iCloud calendar and that works for me.

Other calendars which are RFC 5545 compliant should also work.

From my understanding, Outlook calendars should be compliant to the standard (https://interoperability.blob.core.windows.net/files/MS-STANOICAL/%5BMS-STANOICAL%5D.pdf) but for Office365 I don't know.

The parsing library used to parse the calendar data is ical.js (https://github.com/mozilla-comm/ical.js/) and they offer a parsing tool where you can test your calendar file to determine if it is able to be parsed by ical.js. You can find the validator website here: https://mozilla-comm.github.io/ical.js/validator.html

If you paste your calendar data into the input field you will see that your office365 calendar file format is supported by ical.js. So no problem here.

If I change my own Apple calendar URL from webcal:// to https:// it is working without problems. So you can use a https URL. But http will not work.

By looking at your submitted configs:

  1. The first one is not correct
  2. The last one is correct but I wonder why you did not define any sensors. Will it even work without defined sensors? Does that make sense? Or did you just omit that part of the config?

Sorry, I have no further information at the moment. I will try to test it with an office365 calendar myself, maybe I will get some more insights.

Cheers,
elvirus

@Thilos123
Copy link

Hej @elvirusDE. The reason for no sensors is that, it will add a sensor by default that is called the "Name" variable as a switch that returns 1 when there is an event and 0 when there is none, and that is all i need.

I have tried with a M365 before that worked. So it seems wierd it's not working now.

But. I have found a workaround for my automation. I am using an apple calendar and using a Siri Shortcut to add and remove events from my M365 calender to my Apple calendar that is working just fine.

So you don't need to investigate further for my part. Thanks for looking into it! :-)

@elvirusDE
Copy link

elvirusDE commented Jun 15, 2022

Hej @Thilos123,

thank you for the explanation of the sensors part. I did not know that.

If the workaround is good for you then I am happy that you found a solution. This stuff is always asking for clever solutions. There is always some little detail problem to solve. Nice that it is working for you now.

Cheers,
elvirus

@elvirusDE
Copy link

Hej @Thilos123,

just one more thing:
I found out that there is nothing wrong at all with your .ics file from office365. There is something wrong with the server and how it is processing the request. Unfortunately I don't know more details about it. BUT if I download the .ics file and put it on my own webserver and if I enter that url into the config - then it is totally working.
So if you are able to download the file from microsoft periodically and put it on a server or a storage with a url, you might then be able to use it without siri shortcuts.

And maybe it is a good idea to tell the Microsoft support about that issue.

Best regards,
elvirus

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

No branches or pull requests

7 participants