History says Roger Federer can’t keep playing with fire or his U.S. Open hopes are going to go up in smoke.

Federer was victorious, but nowhere near sharp. Despite grinding out a 3-6, 6-2, 6-3, 6-4 second-round rally against Damir Dzumhur, the five-time champ showed the same cracks in his game that have plagued him lately, and could make a title run tough.

After suffering a straight-set rout in Cincinnati at the hands of Andrey Rublev, Federer dropped the opening set of his first round in Flushing to 190th-ranked Sumit Nagal and looked even worse Wednesday against the 99th-ranked Bosnian.

“When it happens like this back-to-back matches, it’s just a bit frustrating more than anything, especially when the level is that low and there is that many errors and the energy is not kind of there,” Federer said. “But can only do better, which is a great thing moving forward.”

Moving forward — past either Daniel Evans or No. 25 Lucas Pouille in the third round, and to a serious run at his first title here in 11 years — could mean overcoming history.

In 100 U.S Open matches, this was the first time he’d ever dropped the opening set in his first two rounds. No player has ever lost the opening set in the first and second rounds and gone on to win here since the challenger round was abolished in 1912. So, basically, ever.

And nobody has bounced back from dropping their opening sets in their first two matches to take any Grand Slam in six years, since Rafael Nadal managed it at Roland Garros in 2013. To do that, Federer will have to be far better than he was in his first two matches.

“I got exactly what I expected from both guys. I knew what Nagal was going to give me; I knew what Dzumhur was going to give me,” Federer said. “But I didn’t expect to hit 15 to 20 unforced errors, which is basically the entire set just sort of donated.

“But they came out and they were well prepared and got me to do that. But I clearly have to play better from the get-go.”

Clearly. He had 45 unforced errors, and 17 in that sloppy first set alone. Federer committed 11 unforced errors through the first three and a half games, falling behind 4-0 after his forehand — arguably the most lethal weapon in tennis — betrayed him.

Federer alternated between spraying his forehand wide and long. Try picturing Mariano Rivera losing control of his cutter, or Steph Curry the touch on his jumper. Hard to even imagine.

It begs the question of exactly what’s wrong with Fed? Is it being 38? Or a hangover from that tough Wimbledon final loss? With Arthur Ashe Stadium’s roof closed because of rain, wind wasn’t a factor.

“There was literally no wind. OK, now there was zero wind because we were playing indoors except for some ventilation wind, which doesn’t count,” Federer said with a wan chuckle. “I don’t have an answer to you. It’s just poor ball striking in the beginning.”

But Federer rebounded to take the second set. And after Dzumhur sensed his big pivotal moment in the third, he couldn’t take advantage.

Dzumhur was denied a medical timeout despite complaining about difficulty breathing. He still got back on serve, acing Federer to pull within 4-2. Dzumhur eventually called the trainer back to look at his ribs and had three break points on Federer, but let him off the hook.

Federer staved off all three to go up 5-2. And even after Dzumhur breezed through a love service game to make it 5-3 — stalking around the court, mumbling and muttering — the moment had passed and the match was essentially over.