BEIJING (AFP) - As Chinese leader Xi Jinping prepares to embark on a second five-year term this week, the impulsive leaders of North Korea and the United States could spoil his party.
The stability-obsessed Chinese Communist Party has left nothing to chance, ramping up security in Beijing ahead of Wednesday's opening of a congress to re-anoint Xi as general secretary.
Beyond China's borders, Xi has less control.
There, he is at the mercy of two unpredictable men, US President Donald Trump and North Korean strongman Kim Jong Un - a predicament that points to the limits of China's bid to project soft power.
Some analysts say Kim could try to cause a stir by testing another missile or nuclear bomb in the middle of China's most important political event, which is held every five years.
A new test could trigger another 140-character salvo by Trump, who has alternated between prodding and praising Xi's response to North Korea.
Trump's mercurial Twitter diplomacy has contrasted with Xi's unemotional style. The US leader has also pointedly left Xi hanging over whether he will hit China with tariffs over trade grievances.
Despite the mixed messages, Xi has professed his friendship with Trump, confirming an invitation for the US president to come to Beijing next month, when they will discuss trade and North Korea face-to-face.
His relationship with Kim is also complicated.
The North Korean leader has already interfered with two international summits that the Chinese president has hosted this year, by staging headline-grabbing provocations.
In May, as Xi prepared to address world leaders gathered in Beijing on his signature Belt and Road initiative - a Chinese-led trade infrastructure programme - the North successfully launched a new ballistic missile.
Then in September, it conducted its most powerful nuclear test to date, hours before Xi took the stage for a speech before leaders of the developing world at the annual BRICS summit.
The timing was seen as a slight towards Xi and an attempt by Kim to strongarm his Chinese neighbour into convincing Trump to sit down for talks.
A new nuclear test during the party congress "would be more than a loss of face. It will harm the ruling party of China," said Cheng Xiaohe, an associate professor of international relations at Renmin University in Beijing. "It will harm Xi Jinping at this crucial moment."
While the congress will help Xi confirm his status as China's most powerful leader in decades, he has been unable to resolve the biggest international crisis.
His appeals for calm and negotiations to resolve the nuclear row have been ignored by Trump and Kim, who have instead engaged in a worrisome war of words.
And Xi's proposal for North Korea to halt weapons tests in return for the United States to stop military drills with allies in the region has not gained traction.
After a chiding from Trump for failing to rein in Kim, China has implemented tougher UN sanctions against North Korea, and Xi's relationship with the US leader appears to be warming up again.
But Xi has never met Kim and Beijing's relationship with its erstwhile ally appears to be at an all-time low.
Chinese academics have even begun to publicly discuss the previously taboo issue topic of contingencies in case war breaks out across the border.
It is "more likely than not that North Korea will conduct another long-range ballistic missile test" around the time of the congress, said Zhao Tong, a specialist in nuclear policy at the Carnegie-Tsinghua Center in Beijing.
Zhao said the timing was right for another test for Pyongyang to work out remaining technical issues and "conclude the strategic nuclear programme as soon as possible".
"The Chinese leadership would have little extra bandwidth for dealing with North Korea," Zhao said.
"After the party congress the perception is that China would be in the position to focus on North Korean issues. It is safer for North Korea to do it before."