edit: I figured it out, thanks guys!
If they’re untamed, then they will die of age regardless of whether they have adequate food or not. If they are tamed, then you will need to make sure that there is food in the feeding chests or feed them by hand so their food bars are always full.
How do u tame them
You feed them by hand with wheat
How do you know when it’s tamed? Do you just feed them once?
Both donkeys and yaks take about 5 feedings usually (don’t hit them by accident, or it will slow your taming progress). A randomly generated name will appear on an animal once its tamed.
Unfortunately, if those corresponding animals isn’t tamed, regardless of the amount of times you’ve fed it, it will end up a demise of aging.
Precisely, feed carrots 5 times to the corresponding animal, Donkey.
Feed wheat 5 times to yaks.
Don’t make any mistakes while doing so, even a single hit can reset your progress.
Follow this guide.
I always try to isolate the animals that I tame from any of the food it eats as it will eat the food dropped and you will loose a chance to feed it, it also helps if you start when they are first born, infants, as sometimes adults will die before you can fully tame them.