CHICAGO — Todd Frazier began July as somebody who figured to draw interest heading to the trade deadline. He ended the month still on the Mets, after offers that would yield anything of real value never materialized.

But the veteran third baseman still can bring a respectable bat to a solid yet unspectacular Mets lineup.

On Wednesday, he delivered an RBI single in the ninth for the go-ahead run in a 4-2 victory over the White Sox at Guaranteed Rate Field that extended the Mets’ season-longest winning streak to six games.

Frazier, who entered batting just .208 in July — hardly boosting his trade stock after a torrid six-week stretch — said he had a good idea he would be staying.

“I didn’t hear my name the past four or five days being talked about with any team,” Frazier said. “I talked to my agent and nothing was really brewing, so I didn’t have any worries.”

The Mets (52-55) continue to roll against this underbelly of the schedule that still includes another eight straight games against the underwhelming White Sox, Pirates and Marlins. They now trail by just 4½ games for the second wild-card berth.

Michael Conforto’s two-run single provided the insurance after Frazier’s go-ahead single against Jimmy Cordero.

All three runs in the inning were unearned after shortstop Tim Anderson booted Wilson Ramos’ grounder leading off the inning. J.D. Davis singled and Frazier slapped a single to right for the lead.

The rally came hours after the passing of the 4 p.m. trade deadline with Noah Syndergaard, Zack Wheeler and Edwin Diaz still on the roster. For all the buzz about a potential overhaul, the Mets’ only move was essentially swapping Jason Vargas in the rotation for Marcus Stroman.

“The last eight hours have been huge for us,” Conforto said. “All the guys are staying here. Whatever we can do to find a way to the playoffs. We’re playing some teams we feel we can do real well against and we’re motivated.”

Diaz earned the save, but it wasn’t seamless — he surrendered a solo homer to Leury Garcia in the ninth, a night after he had blown the lead and the Mets needed extra innings for the victory.

The White Sox threatened against Justin Wilson in the eighth inning, loading the bases on Jon Jay’s grounder that struck second-base umpire Stu Scheurwater for a single. The ball was ruled dead, sending go-ahead run Ryan Goins back to third base. Wilson then retired Anderson to keep it 1-1.

Jacob deGrom gave the Mets a chance by allowing one run on five hits and two walks over seven innings with 11 strikeouts. The double-digit strikeout game was deGrom’s third in his past five starts and 39th in his major league career.

The right-hander ran his pitch count up to 116 as he struck out Garcia to end the seventh and stranded the go-ahead run at second base. DeGrom had a scoreless streak snapped at 19 innings earlier in the game. The streak was the longest by a Mets pitcher this season.

“Everybody is having fun,” deGrom said. “The pitching, we’ve been throwing the ball well and keeping us in games and these guys have been putting up runs.”

Over his last 13 starts, dating to May 22, deGrom has posted a 2.04 ERA. But the Mets are just 5-8 in those games.

Conforto hustled home on Wilson Ramos’ grounder to third base in the sixth to tie it 1-1. Robinson Cano sparked the inning by snapping an 0-for-23 — the longest drought of his career — with a single to center that put runners on the corners. Conforto started the rally with a leadoff walk against Lucas Giolito.

The right-hander Giolito surrendered just three hits over seven innings, escaping trouble in the sixth by getting Davis to hit into a double play after the Mets had already scored once in the inning.

DeGrom struggled with control in the third, walking two batters and surrendering two singles, but escaped with only one run scoring. Jose Abreu hit a sacrifice fly with the bases loaded to give the White Sox a 1-0 lead. After deGrom walked AJ Reed to reload the bases, Eloy Jimenez struck out to end the inning.