Trump later tweeted that the United States is considering cutting trade with all countries that do business with North Korea — including, presumably, China.
Asked about the trade tweet at a regular news conference on Monday, Geng Shuang, a spokesman for the Chinese Foreign Ministry, called it "unacceptable."
The unwelcome interruptions show just what Xi is up against as he decides how to respond to North Korea's provocations and pressure from an unpredictable U.S. president, while also preparing for a twice-a-decade political meeting next month.
"China has been cornered," said Cheng Xiaohe, a North Korea expert at Renmin University in Beijing. "I'm afraid of what we are facing now. We are at the stage of a showdown."
Xi does not want a showdown. The National Congress of the Communist Party of China, which starts Oct. 18, will be a key moment in his presidency. It is a chance for him to prove he has consolidated power and has a plan for the years ahead. The meeting is years, not months, in the making; very little is left to chance.
In the run-up to the conclave, state media has been praising Xi in overdrive, calling on cadres to study and implement his "diplomatic thought." A six-part television documentary series looked at Xi's "remarkable diplomatic achievements."
A nuclear bomb near the border and presidential put-downs are way off-script in this environment.
"With the congress coming up, this is the last thing China wants," said Adam Cathcart, a lecturer at Britain's University of Leeds. "You've got a bomb coming and banging on his podium."
Though Sunday's test will lead to louder U.S. calls for a crackdown on Kim, China is unlikely to listen, Cathcart said. "This is the last moment they would be executing a pivot toward an American vision about what to do with North Korea."
There was a time when China and North Korea were Communist brothers-in-arms — but that time is long gone. China, like the United States and the rest of the world, is both frustrated with and frightened by Kim.
Ordinary Chinese have no love for the leader they call "fatty Kim the third." Beijing does not like the young dictator testing missiles close to the border, especially when those tests feel like taunts.
In May, Pyongyang launched a missile hours before Xi was set to give a major speech on one of his signature bits of foreign policy, the infrastructure bonanza known as "One Belt, One Road." Sunday's test came hours before Xi was set to address an international relations conference, the BRICS summit, attended by Brazil, Russia, India, China and South Africa in southern China.
"We all knew that President Xi was to make a speech at the BRICS summit today, and North Korea chose this time to conduct testing, especially H-bomb testing," said Renmin's Cheng. The timing, he said, is "inconceivable."
But China sees limited options, experts said. While some in the United States would be happy to see Kim fall, China has no interest in instability on the Korean Peninsula. China sees any change to the status quo as a potential opening for the United States to increase its military presence in Asia.
China has responded to months of North Korean tests by proposing a "double suspension" plan that would see the United States and South Korea suspend joint military exercises and North Korea suspend weapons testing. Beyond that plan, which is unlikely to proceed, Beijing has backed U.N.-led sanctions and called for a return to talks.
The Chinese Foreign Ministry on Sunday issued a statement saying it "resolutely opposed" and "strongly condemned" the test. The statement called on the international community to come together to implement U.N. resolutions and nudged North Korea to come back to the table — familiar stuff.
The question now is whether China will do more than support another round of U.N. sanctions. China is North Korea's largest supplier of crude oil; some have called for China to suspend supply.
That is still possible, but the Chinese side has yet to put it on the table, and early signals suggest it won't.
In an article published shortly after the nuclear test, the Global Times, a party-controlled newspaper known for its nationalistic tone, predicted that China would not change course.
In a video interview, the paper's outspoken editor, Hu Xijin, said he was angry but could not support tougher sanctions. "I want to tell the citizens of the world, most Chinese feel the same way you do: We are angry about North Korea's nuclear test," he said.
But, he argued, a total embargo was not the way forward. Cutting off Kim would not stop nuclear testing but could turn the dictator against Beijing.
"Therefore, despite my own anger, I advocate that Beijing put China's national interests first, and not readily agree to a total embargo including oil."
Shirley Feng and Yang Liu in Beijing contributed to this report.