Insomnia is about chasing the impossible, about lying awake and trying not to focus on the only thing you can think about, occasionally drifting down the slope toward sleep and then — sensing this! — jolting awake once more. Like money, sleep functions on a delicate web of trust, and Samantha Harvey’s often brilliant and sometimes frustrating new book anatomizes what happens when we stop believing.

Harvey is a British novelist who has published four novels to critical acclaim but muted sales, and was well on her way to the uncoveted status of writer’s writer when in mid-2016, disaster struck. Moving to a new home on a noisy road, and with her equilibrium unbalanced by anger at the United Kingdom’s vote to leave the European Union, she stopped sleeping.

The Shapeless Unease” is subtitled “A Year of Not Sleeping,” but this is doubly misleading: First, Harvey suffered for more than a year (it was still happening late in 2018, when she published an essay about it); and second, it wasn’t quite not sleeping. Most nights Harvey did sleep, but fitfully, unsatisfactorily, which she deliciously details. The outline will be familiar to anyone who has ever struggled to get to sleep or to get back to sleep: the quantity-surveying (it’s still only two o’clock; I can get four hours’ sleep if I go now), the going-to-bed routine recommended by sleep experts that only serves to emphasize the problem.

Harvey conveys the hell of insomnia with the precision and passion of one who has come to know it too well. “There’s terror when a basic animal need isn’t met. At first you fear death, then a worse thing happens — you fear life. You no longer want your life, not on these terms.” For her, the body’s last job each night has become the thing she dreads all day, right from the moment she wakes up, or more often doesn’t wake up. “I go up to bed at night, I get beaten up, I come downstairs in the morning.”

The cause of Harvey’s sleeplessness was plainly anxiety, an inability of the mind to sit still, initiated by Brexit and the upheaval of a new home but then efficiently self-sustaining. She discussed it with her doctor and therapist and reproduces extracts from these circular, combative conversations, where, if you look hard enough, there’s black humor in a champion insomniac being told that it might help if she could learn to relax before bed.

When “The Shapeless Unease” remains focused on its subject, it engages and grips. Harvey complains about the futility of describing the feeling of insomnia, but she does as good a job as you would expect a gifted novelist to at relaying the brain fog, the mind turning in on itself. Her relationship with writing becomes ambiguous: On the one hand, it is impossible (“I sit there and start a sentence and have no idea what word will come next or how I’ll find my way to the end of it” — wait, that’s not normal?). On the other hand, “writing has saved my life,” she writes. “I am sane when I write, my nerves settle.”

This may explain why so much of the book contains writing that seems to be there purely for its own pleasure. Harvey fills pages with rants about British jingoism, presumably representative of the flailings of the nocturnal mind, but sounding like an op-ed columnist making bricks without straw. She includes a story she wrote during her period of insomnia, about a man who steals vast sums of money from ATMs, which takes up around one-sixth of the book but seems untethered to the subject.

And she includes numerous digressions of tangential relevance: Buddhism, William James on reason, the limitations of language used by the Amazonian Pirahã people. There’s no question that these are all beautifully done — particularly a half-page portrait of Harvey’s deceased cousin — but the creaks are audible as she tries to link them back to her topic.

More frustrating still is when she gives us tantalizing glimpses of other material which surely must be relevant to the state of mind feeding her insomnia: her ambivalent relationship to being without children; her childhood with a semiliterate father (“first book he ever read was the first book [I] wrote”). And there is nothing on the science of insomnia, nor its cultural history. Harvey does gesture outward a few pages before the end, with discussion of Shakespeare’s references to sleep. But, like finally falling into peaceable slumber at 6 a.m., it’s just too late.

John Self is a book critic. He lives in Northern Ireland.

The Shapeless Unease

A Year of Not Sleeping

By Samantha Harvey

Grove. 192 pp. $24