I wanted to provide a personal story to counter a lot of the enthusiasm and carelessness around modafanil. I'm a software engineer, and I've dabbled on and off with modafanil for a little less than a decade now, including several one-week runs of hardcore usage, without sleep, during contracting gigs in my early-mid twenties.
I'll start by saying that I still think modafanil can be extremely useful as a tool, and that, until I recently ran out, I would still take 100-200mg of modafanil if it were no more than once a week (with an effort to make it not more than twice a month), so I still feel the risks and unknowns can be worth the tradeoff. But make no mistake - modafanil is an effective medication, and like all effective medications, it has side effects, (light) mental habituation, and potentially life threatening side effects if used improperly.
At the end of one particularly rough 9 days or so of straight usage during a major release for a contract, averaging 3 hours of sleep once every two to three nights (and the rest solidly awake), I settled with the team at a 24-hour diner right before release, and had an all-potato breakfast. My stomach had been steadily gaining in acidity over the week, but I had ignored it. A couple of hours later, I threw up and accidentally inhaled a small amount of the most corrosive stomach acid I've ever felt. When I coughed it out I tasted blood, and shortly after found it harder to breath. The bleeding was so profuse that I found it necessary to handstand over a hotel bathroom sink to let it all drain out without choking me. Luckily the person who had dropped me off was nearby - I phoned him and he took me straight to the hospital. I never had experienced that level of lung trauma before, and I've had a lot of hospitalization events related to some pretty severe asthma in my life, and it was this moment more than any other in my life that I seriously considered that I might die. In the end, I made it out with a light lung infection, and was treated at the hospital for an allergic reaction. I've never been able to eat potatoes since without experiencing an allergic reaction.
I can't seem to find a citation for this right now, but I remember reading at one point that modafanil is an agonist in the histamine receptor family. I am not a neurologist, and I know that the histamine receptor family can have very contradictory effects due to them being a modulator of the release levels of neurotransmitters dopaminergic and serotonergic pathways, and is also more publicly famous as being the target of the antagonist, Benadryl. I generally think about the vigilance instilled by Provigil as the same kind of vigilance you may have experienced during the beginning stages of an infection. The immune system revs up, you get warmer, you don't want to move around as much (as opposed to amphetamine based stimulants that seem to give you physical energy you want to burn off), and you slip into a more introspective and determinedly focused state. But vigilance comes at a price, and if you keep burning carelessly through your internal resources without replenishing them, eventually you'll start burning the wick (you) too. Something will fail. Sometimes catastrophically.