It partly depends on when; the earlier the better, generally. When the US became more intervention-oriented, China's initial response was to prepare for their own country being invaded, and urged the DRV to retire to the hill country, rather than stand and fight, but as Johnson dawdled through 64-5, they became more secure in aiding the DRV, sending them logistical and AA personnel and thus freeing up more men for the conquest of the RVN. At that point, actually killing Chinese soldiers in ground combat ran a serious risk of provoking an international conflagration.
If China did intervene, though, it's hardly an instant loss scenario; the nature of the country meant that the Chinese could probably only deploy about 20 divisions into SE Asia, and the US military thought 8 American divisions would be more than a match for them without the use of any nuclear weapons. China wasn't that eager for a Great Power war with the United States after the Korean War either. In terms of writing a timeline, China not intervening directly after an American invasion in 1964 and Chinese intervention resulting in stalemate along the 17th Parallel are fairly plausible.
Considering their troubled relationship with North Vietnam and China, I don't think the Soviet Union would initiate a strategic nuclear exchange over North Vietnam. China alone didn't have a nuclear stockpile in the same universe as the US in the 60s, and probably wouldn't initiate an exchange without Soviet assurance, which would be difficult to come by.