Good tips from retrolefty.
Worst case for that circuit is if it is disconnected when the voltage is at one peak of the sine wave and reconnected when it is at another.
That puts about 170V charge on the capacitor. Plus 170V from the powerline in the opposite polarity, putting 340V on the 1k resistor and 340mA through either the 1N914 or the optoisolator. It might not fail right away.