I replace the slide-lock spring every 10,000 rounds. If you wait too long, this part will break in half and your slide will fall off of the frame when it fails. Best to just spend $8 every 10K rounds and keep your gun in perfect running order, as a part of required, periodic maintenance rather than suffer a complete stoppage at an inconvenient time.
Keep good records so that you know when to replace various components! But anyway, here’s how to do this one replacement on any Gen 1 thru 4 Glock pistol.