Based on the latest work with my collaborators, a massive star would need to be within about 150 light-years to cause measurable damage. We think that may have happened about 2.6 million years ago, and possibly contributed to an extinction event at the end of the Pliocene era that took out marine megafauna. (See the November 27, 2018, issue of the journal Astrobiology, and “Could a supernova explain an ancient mass extinction?” on page 11 of Astronomy’s April 2019 issue.) A supernova within about 25 light-years would probably cause a major mass extinction, which has likely happened one or more times in the past 500 million years.
The biggest current threat is probably a solar proton event, which occurs when the Sun releases high numbers of energetic protons that can disrupt communications and affect power grids. These events could be devastating for our technological civilization.