Warning: This article contains major spoilers for "A Flash of the Lightning," the latest episode of The Flash Season 6.

The Season 6 premiere of The CW’s  The Flash brought a grave warning from the future. Near the end of the episode, The Monitor appeared to Barry Allen and Iris West and informed them that the Scarlet Speedster would die in the upcoming “Crisis on Infinite Earths,” this December’s highly-anticipated Arrowverse crossover. Now, in the season’s second episode, “A Flash of the Lightning,” Barry and Iris are still reeling from The Monitor’s shocking revelation, and needless to say, they want to change Barry's destiny.

In order to find a way to circumvent his fate, Barry tries to travel to a couple of months into the future, to see what happens the day following his foretold demise. Unfortunately, a wall of anti-matter prevents him from reaching his destination. Instead, the superhero opts to travel to Earth-3, where Jay Garrick offers a helping hand. And there, The Flash ends up stealing a page right out of Doctor Strange’s Avengers: Infinity War playbook.

RELATED: Arrow Had to Clear the Destruction of [SPOILER] with The Flash Writers

Because of the anti-matter wall inside the Speed Force, Barry is unable to time travel past the events of “Crisis on Infinite Earths.” However, in his speed lab, Jay Garrick has the next best thing: a machine which can send a speedster’s mind forward in time, connecting to his future self. Once he's hooked up to the machine, Barry catches a glimpse of the coming Crisis and the total destruction of the Earth at the hands of the Anti-Monitor. When he wakes back up, he is obviously quite shaken, and it takes a bit of time for him to recuperate.

Later, Barry tells Iris that he saw billions of possible futures unfold at super-speed. In each and everyone of them, the Earth and everyone he loved was gone. He explains that the only future where the world is saved is the one where he makes the ultimate sacrifice and dies. And so, Barry now knows the only way to save the entire universe.

RELATED: Arrow: What Does the Final Season Premiere Mean for the Flash?

Doctor Strange Avengers Infinity War

If that sounds familiar, it’s eerily reminiscent of Doctor Strange’s plan in Avengers: Infinity War. As fans may recall, in the film, the Sorcerer Supreme used the Time Stone to peer into 14,000,605 futures where the Avengers lost the fight against Thanos, and he had to die to make it happen. Of those outcomes, there was only one where the Avengers triumphed — a sequence of events that would unfold all the way through Avengers: Endgame.

Of course, in order for the Avengers the save the universe, Tony Stark/Iron Man made the ultimate sacrifice. Now, for “Crisis on Infinite Earths,” the Flash has just taken inspiration of a sorts from Doctor Strange. He’s seen an infinite number of possible futures, and the only way to save everyone involves his own demise and the ultimate death of one of his best superhero friends. And in both cases, it just might cost the life of a great, if not the greatest, superhero in the world.

Airing Tuesdays at 8 p.m. on The CW, The Flash stars Grant Gustin, Candice Patton, Carlos Valdes, Danielle Panabaker, Tom Cavanagh, Jesse L. Martin, Danielle Nicolet and Hartley Sawyer.

KEEP READING: The Flash's First Glimpse of Crisis Is Straight Out of the Comics