Mr. Trump has not had a medical emergency while running for or serving in office, though he has not released as much medical information to the public as other recent presidents have. This year, the White House physician pronounced Mr. Trump in “very good health,” although the president had gained weight and is now officially obese.

Other presidents and presidential candidates have had heart trouble, though not all of it was known to the public at the time. Experts believe that President Warren G. Harding died of a heart attack that his doctor did not detect. Toward the end of President Franklin D. Roosevelt’s third term and until his death in his fourth term, his White House doctor withheld the fact that he had serious heart failure. President Dwight D. Eisenhower suffered a heart attack near the end of his first term, and might have had a heart attack before he ran for president.

In 1999, former Senator Bill Bradley damaged his presidential campaign by not disclosing that he had had a number of episodes of atrial fibrillation, a heart rhythm abnormality, before he experienced one while campaigning and had to be rushed to a hospital with reporters trailing him.

Before his heart attack pulled him from the campaign trail, Mr. Sanders was polling in the top tier of the Democratic primary race with Mr. Biden and Ms. Warren, and his staff has been trying to project optimism about his candidacy. But the episode has cast a shadow over his campaign just as he was attempting to reinvigorate it after a summer slump that saw his standing in some polls slip.

Hoping to reverse course, he had recently begun to focus more on his electability, arguing that he is the candidate best positioned to beat Mr. Trump in the general election.

The Sanders campaign announced this week that it had raised $25.3 million in the third quarter, placing him ahead of Ms. Warren, his chief ideological rival, by a hair and at the top of the field in fund-raising.

In a show of force, the campaign announced a $1.3 million ad buy in Iowa that it then postponed as it waited to assess the situation; the ad will now begin airing next Tuesday, and will run for two weeks as planned.