Afterward, having come oh-so-close to pitching a no-hitter with his family in the stands willing it to happen, Alex Cobb took a moment to thank center fielder Austin Slater for the sensational diving catch that preserved the bid.

Cobb did the same with Giants manager Gabe Kapler, offering up some gratitude for being given the opportunity. Kapler stuck with Cobb even as his pitch count went higher than it had ever been.

Cobb came within one out of a no-hitter before Spencer Steer doubled with two outs in the ninth inning of San Francisco’s 6-1 win over the Cincinnati Reds on Tuesday night, settling for a spectacular complete game. His 131 pitches were the most in his career and the most by any pitcher in the majors this season, and 83 were for strikes.

“Still right now, this is surreal,” Cobb said. “In the moment, I was just focused on the delivery and the game plan and executing pitches, and then it started to become real. Had some cool thoughts going on in my mind of having my family here and thanking them. It was special, for sure.”

Cobb nearly notched the majors’ fifth no-hitter this year, dazzling with his split-finger fastball to shut down Cincinnati before Steer’s double provided the Reds’ only run.

Fans cheered the 35-year-old right-hander after the hit with chants of “Alex Cobb!” Once the final out was recorded, Cobb hugged teammates and coaches and acknowledged the crowd.

Slater made the defensive play of the game when he chased down a shallow fly ball by Will Benson with an improbable catch in left-center to end the eighth — and Cobb raised both arms in celebration.

Even Kapler thought that would be a hit.

Cobb just missed tossing San Francisco’s first no-hitter since Chris Heston on June 9, 2015, at the New York Mets.

After getting Noelvi Marte‘s first-pitch flyout to start the ninth, Cobb (7-5) issued a one-out walk to Nick Senzel before another fly to right by TJ Friedl. Then Steer came through with an opposite-field hit.

“Still fun,” said Cobb, the game ball safely tucked away in his corner locker with some other keepsakes like his strikeout from this year’s All-Star Game — his first. “I wasn’t mad, sad, just, ‘All right, let’s finish it off’ kind of thing.”

A run scored on the double, and Cobb threw a called third strike past rookie Elly De La Cruz for his eighth strikeout, sixth career complete game and second this year.