During heavy rain, my RPM pressure will randomly drop and then the vehicle stall on 2005 Hyundai Sonata

At which point it will not turn over the check engine and battery light come on. The dealership has replaced the catalyst converter, the cam sensor and the ignition sensor and it happened again last night, this is the 4th time in less than a year this has happened. Any ideas?

Asked by for the 2005 Hyundai Sonata
sounds like electrical system is getting wet and shorting out. return for warranty work asap