"TypeError: Cannot read property [functionName] of undefined"

I have an application that creates files, and allows the user to delete them when they’re no longer necessary. For several months I’ve had this working, but it’s suddenly stopped working and I can’t figure out why.

My app consists of several pages, a service that hosts functions/methods shared by those pages, and a service that deals with File System I/O. A given page will called the “SharedServices” Service to delete a report, which in turn calls the “FileServices” Service to remove the file from storage.

It’s been working this way without any problem, but just recently I’ve run into an issue where the “SharedServices” Service throws this TypeError when it tries to called the “deleteRecord” function in the “FileServices” Service. Everything compiles just fine, so I don’t understand where the problem is.

Hello,

without code nobody can really help you.

At the time you call whatever.deleteRecord whatever does not exist. For the compiler no problem because js is late bound. Maybe you have changed something that cause this, maybe a livecyle problem, maybe a await/async/promise timming problem, maybe…

Best regards, anna-liebt

I understand the problem with a lack of code. It’s just very complex, and my boss is paranoid about sharing our source code so I’m not sure how to post enough-but-not-too-much code here. Not really helpful to anyone, I know.

My issue seems to be that the “FileServices” service is throwing an undefined error in the “SharedServices” service when I try to call the deleteReport() function in it.

I’ve made sure that the service is both imported and referenced in the constructor, so I’m not sure why the page is saying that it’s undefined.


Possibly related, I’m seeing new errors when I compile saying that there is a circular dependency between the two Services. Forgive me if this sounds amateurish, but is that causing an infinite loop of importing, leading to the “SharedServices” reporting that the finitely-loading “FileService” isn’t defined?