How to catch and fix these on the fly? That would be difficult..
But this is an issue you really should not have.
Could it be an issue with filament storage?
Or is it coming from the manufacturer with these bulges? If so, I would try contacting ( you may have gotten a bad batch? ), or finding a new retailer if this happens often.
I have gone through a lot of pounds of both ABS and PLA and never come across this.