Even in the extreme case of North Korea nuking Japan, it would still lead to an extremely complex international situation. The US retaliating for Japan with a nuclear strike or any similar situation of extreme force would be a far too risky of a move.
Not only is NK important to China strategically as a buffer between themselves and the US friendly South Korea, but the Chinese people feel a kinship with the people of NK, not entirely dissimilar to the way the US views Canada culturally. Aggressive retaliation would unquestionably make China an aggressive and active enemy of the US (or whoever decided it was their job to retaliate).
North Korea's proximity to China, not just physically but culturally as well, makes the issue far more complex than if a rogue nation where make similar threats.
"They have a close special relationship and China is often considered to be North Korea's closest ally. China and North Korea have a mutual aid and co-operation treaty, which is currently the only defense treaty either country has with any nation." [0]
[0] https://en.wikipedia.org/wiki/China%E2%80%93North_Korea_rela....