Kaley Cuoco and her co-stars from The Big Bang Theory are sharing details of the scary horseback riding accident that nearly resulted in her leg being amputated more than 10 years ago.

The actress, 36, opened up about the incident alongside co-star Johnny Galeckiand Big Bang creator Chuck Lorre in an excerpt from The Big Bang Theory: The Definitive, Inside Story of the Epic Hit Series (written by Jessica Radloff) shared with Vanity Fair.

“That was the darkest, most frightening time in all twelve years [of the show],” Lorre said. “Kaley could have lost her leg. It was a series of miracles that allowed us to get through that and for her to come out the other end of that healthy.”

“They were talking about amputating her leg, which was devastating to hear,” Galecki, 47, added.

In September 2010, Cuoco, who’s an avid horse jumper and competitor, was riding at a Los Angeles ranch when her horse got spooked and she fell off. Seconds later, the horse attempted to jump over her but landed on her left leg. Cuoco was rushed to the hospital with severe injuries.

Lorre noted that it was “heaven-sent” that he ran into Dr. Stephen Lombardo, who’s part of Kerlan Jobe Orthopedic Clinic for Sports Medicine at Cedars-Sinai, and asked for help with Cuoco’s leg injury. In less than two hours, he said the actress was “in surgery with the best surgeons available to stop an infection because her leg was wide open.”

In the excerpt, Cuoco shared more: “Before I went into surgery, they made me sign something that said, ‘We don’t know until we get in there and see this leg, and it could come out that you don’t have it anymore.’ That wasn’t the case, obviously, but I had to sign something that said, ‘OK, you can,’ ” Cuoco said in the excerpt. “Everything ended up fine, and I was up and working a week later, but the doctors acted like I was never going to walk again. It’s still too much for me to go into, and it sounded way worse than it was. And of course it was spiraling and everyone was freaking out, which I get. It scared people.”

“But I think it scared people in a good way, myself included,” Galecki said. “The first day I saw you in that state, I just shed tears in my garage.”

Doctors originally believed Cuoco wouldn’t be able to walk for months. However, after a two-week stay in the hospital, she was fitted for a walking boot and back on her feet. The accident resulted in Cuoco being written out of two episodes of the Big Bang, but Lorre admitted that the possibility of an amputation could’ve ended the CBS hit sitcom.

“It was an absolutely miraculous intervention that I ran into Dr. Steve,” Lorre said. “Every time I see him, I say, ‘Thank you! You saved Kaley! On a lesser level, you saved The Big Bang Theory!'”