In a summer of messy air travel, this week may rank among the worst.

Thousands of travelers were stuck at airports across the country after Spirit Airlines canceled hundreds of flights per day, for days in a row. On Wednesday, the carrier canceled 60 percent of its flights. On Thursday morning, another 51 percent.

“The last three days were extremely difficult for our Guests and Team Members, and for that we sincerely apologize. We continue to work around-the-clock to get our Guests where they need to be,” Spirit said in a statement.

Spirit wasn’t the only airline facing challenges this week. American Airlines also canceled a significant number of flights at its Dallas-Fort Worth International Airport hub between Sunday and Wednesday.

Are these cancellations — caused by weather issues, labor shortages and “operational challenges” — going to end anytime soon?

“For American … it seems to be improving significantly,” says Scott Keyes, founder of Scott’s Cheap Flights and author of “Take More Vacations.” “For Spirit, Lord help you. I have no idea when things are going to get better.”

Keyes says overall the cancellations are indicative of a larger trend. Airlines have to make an educated guess months in advance to plan their operations, and this year “essentially their eyes were bigger than their stomachs,” he says.

While the number of people flying again has been a best-case scenario for airlines, “the staffing, the number of folks working, in many ways been a worst-case scenario,” Keyes says.

So what should you do if you’re worried whether your flight will actually take off? Here’s what experts advise.

If you get rescheduled

You may not know your flight is going to be rescheduled until the last minute — maybe even after you have arrived at the airport. Katherine Estep, a spokeswoman for the advocacy group Airlines for America, recommends downloading your carrier’s app to get immediate updates on your flight schedule.

Should your flight get significantly delayed, you are entitled to a refund (if you ask for one), per Department of Transportation regulations. However, every airline has a different definition of “significantly.” You will have to check with your carrier to find out if you are eligible. Even if you’re not, you may be able to get compensation for the disruption. Ask the airline if you are eligible for a meal voucher or a hotel room for the night while you wait.

Don’t like the rebooked flight? “Keep an eye on backup plans,” Keyes says. “If your flight were to get canceled, what are flights that this airline has that would work for me and my schedule?”

Once you have picked a new flight that works for you, get on the phone with customer service (which can be tough with long wait times, but here are some tips for that, too) and request it specifically.

“That’s going to be much more fruitful than saying, ‘My flight got canceled, what do I do?’ ” Keyes says.

The hyper-transmissible delta variant of the coronavirus has left would-be travelers uncertain. The Post spoke to an expert about how to safely make that call. (The Washington Post)

If your flight has been canceled

The bad news is your flight has been canceled. The good news is you are owed a refund. The same Department of Transportation regulations we mentioned above entitle you to a refund.

But be warned: Accepting the canceled flight, getting your money back and starting from scratch may put you in a position of scrambling for a more expensive flight, if you can find one at all. Then there’s the risk that your new flight may be canceled or delayed. You may want to reschedule a new flight with the airline vs. going for the refund.

If you want to be protected

There are a few things you can do to put yourself in a better position for this uncertain time of flying.

Protecting yourself starts when you book the flight. Brian Kelly, the founder and chief executive of the Points Guy, recommends booking your flights with frequent flier miles.

“Most airline frequent-flier programs will actually refund your points and taxes and fees, so it’s kind of like buying a refundable ticket,” Kelly says. “They give you maximum flexibility.”

Look for nonstop flights to your destination that depart earlier in the day. You will have fewer variables to deal with, and should something go wrong, you’ll have more rerouting options than if you were departing later.

Martin Nolan, a traveler rights expert at Skyscanner, recommends booking a flight with a flexible fare that allows for a free date or destination change. He also suggests booking travel with a credit card that offers extra protections. A good credit card company will go to bat for you if you are struggling to get a rightfully owed refund.

Adit Damodaran, economist at the travel booking app Hopper, says it is wise to prepare for the worst by padding your trip with some buffer time if you’re traveling for a special event. Don’t cut your arrival too close; find a flight a day before in case there is a delay or cancellation. Hopper also has “Rebooking Protection Services,” allowing travelers to fly on another airline if there is a disruption.

Keyes strongly urges travelers to skip checking a bag.

“If you have checked a bag and then you get to the gate and your flight gets canceled or delayed, it’s going to be more difficult to get switched to a different flight,” he says. “If there’s another flight that’s leaving 15 minutes from now or 20 minutes from now, your bag is not going to make it.”

Instead, get to the airport early, and make sure your carry-on bag is stocked with snacks. Travelers have been racking up horror stories of spending an eternity at an airport with no food to be found. Hopefully you won’t need to rely on what you pack and can take off according to schedule.

“Even as this is happening, the vast majority of flights writ large are still taking off on time,” Keyes says.