obsidian-tasks
obsidian-tasks copied to clipboard
Stuck on "Loading Tasks..." due to "Cannot read properties from undefined...Function.getTasksFromFileContent"
Expected Behavior
Tasks successfully load into a markdown note using the correct syntax e.g.
not done
heading includes todo/scratchpad
Current behaviour

Steps to reproduce
Query:
not done
heading includes todo/scratchpad
Which Operating Systems are you using?
- [ ] Android
- [X] iPhone/iPad
- [ ] Linux
- [X] macOS
- [ ] Windows
Obsidian Version
0.15.9
Tasks Plugin Version
1.11.1
Checks
- [X] I have tried it with all other plugins disabled and the error still occurs
Possible solution
I did end up fixing it. Here's how:
- I installed
tasks
locally and reran the uncompiled version - I added the following code:
if (line === undefined) {
console.log(path + ' path');
console.error('line is undefined');
return null;
}
console.log(line);
const regexMatch = line.match(Task.taskRegex);
if (regexMatch === null) {
return null;
}
- From there, I was able to see that the problem path was throwing this error:

- I found the file that was causing the error and cleaned it out, "unstucking" Tasks.
Recommendation: the error surfaced in console
wasn't too helpful on its own. A try catch around this line: https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/Task.ts#L237
that exposes the arguments of what the offending line is (a stack dump of the arguments: line, path, sectionStart, sectionIndex, precedingHeader) would allow for user debugging without needing to locally install
Closing this issue since it is technically solved on my own machine, but I hope this is useful @claremacrae!
Thank you very much for logging this.
I'll re-open it for visibility, or we will never seen it to do anything with it.
@bramses Nice debugging and good suggestion! When you say you "cleaned out" the file that was causing Tasks to get stuck, do you have any idea what type of syntax you needed to clean to make the issue go away?
@AnnaKornfeldSimpson thanks! Basically in my case I have an "read later archive" file of todo links (think online articles I save for later and such), and one of them -- still not sure which one since I only debugged the path
was bugging. So I removed [x]
from all of the archived elements and Tasks started working again
Thank you very much indeed. Just noting some possible things that come to. mind:
- the call-stack/traceback shows the error was in variable
match
being undefined in a functionfromLine()
called fromCache.getTasksFromFileContent()
- Could there be a problem with a regex that doesn't work with unicode characters?
- I am suspicious
Cache.indexFile()
usingmetadataCache.getFileCache(file)
and its possibility of reading out-of-date file context.- What if a file is updated via sync whilst its contents are being read?
@bramses if it happens again, or if you can restore the offending file from backup, it would be really helpful to know what the line or character was that caused the problem please. That way I could fix the underlying issue.
Could there be a problem with a regex that doesn't work with unicode characters?
Possibly! These links come from all over so I wouldn't be surprised if a few had weird Unicode symbols.
What if a file is updated via sync whilst its contents are being read?
I use sync
and git
so one of them might've put a file into a weird state 😅
if it happens again, or if you can restore the offending file from backup, it would be really helpful to know what the line or character was that caused the problem please. That way I could fix the underlying issue.
I'll let you know if it pops up again! FWIW the line itself was undefined (which is why I added the conditional) so perhaps its not getting set somewhere upstream?
I will be tracking this issue in #829.