Riley Keough accidentally caused a movie she was working on several years ago to be shut down because she ate a granola bar with peanuts before a kissing scene with Andrew Garfield.   

The 34-year-old said she had no idea the "Spiderman" actor, with whom she was co-starring in 2018's "Under the Silver Lake," was allergic to peanuts and that the situation was "actually very stressful."

"I was in the makeup trailer and I was eating like a granola bar or something, and I was about to shoot a scene where I have to kiss Andrew, and the makeup lady was like, 'Are there peanuts in that?' And I was like, ‘I think. I don’t know,’" she told Vanity Fair in a video interview released Tuesday. 

The actress said the makeup woman ran off and got a producer friend of Keough’s who told her, "Riley, Andrew's very allergic to peanuts and we have to shut the set down."

RILEY KEOUGH SAYS FILMING SEX SCENE WITH HER REAL-LIFE HUSBAND WAS ‘REALLY UNCOMFORTABLE’: ‘IT WAS REALLY WEIRD’  

Split of Riley Keough and Andrew Garfield smiling

Riley Keough says she didn't know Andrew Garfield had a peanut allergy when she ate a granola bar before almost doing a kissing scene with him. (Arnold Jerocki/Getty Images / Karwai Tang/WireImage)

She said the producer added that the granola bars shouldn’t have been allowed at craft services, the food provided on movie sets. "I don't know why they're on set," the producer said. 

"I was kind of like, ‘Oh, f---, that’s crazy,'" Keough said. "But also, like, thank God that this woman caught it, ‘cause I had no idea."

Years ago, Garfield told Marie Claire he once went into anaphylactic shock while out to dinner with "Never Let Me Go" co-stars Keira Knightley and Carey Mulligan. 

"When we were filming in Norfolk, I went to dinner with Carey and Keira one night. There I was sitting in between these beautiful girls, when I started having an allergic reaction to something in my food," he told the magazine, according to Express. 

CLICK HERE TO SIGN UP FOR THE ENTERTAINMENT NEWSLETTER

Riley Keough with Andrew Garfield

Keough and Garfield starred together in 2018's "Under the Silver Lake." (Donato Sardella/Getty Images for InStyle)

CLICK HERE TO GET THE FOX NEWS APP

"I had to spend the rest of that night in hospital," he continued. "[Screenwriter] Alex Garland took me. I'm used to it, because I've been in hospital a few times with this, but Carey was beside herself and Keira was terrified. It was just the most awkward moment ever, to go into anaphylactic shock at dinner."