Esp32 gpio switch cable length?

I have an ESP8266 configured with reed switches that monitor three doors in my garage. Each reed switch connects to a GPIO pin configured as a switch. Pull_up enables. When closed, the reed switch pull the GPIO pin to ground. A few months ago one of the GPIO pins stopped working. I fixed the problem by moving the reed switch to an unused GPIO pin and reconfigured the device to work with that pin. Last week I had the same door switch fail. While troubleshooting I found the pin seemed to be floating as it’s output was oscillating between on and off.

A question of curiosity, could the length of the cable between the device and the reed switch be causing the ESP8266 to fail? Or did I just get a bad device?

It’s a good idea to add external pull-up resistor when cables are long. Internal one is pretty high ( i think it’s in the range of 50kohm), so when cables are longer noise can be easily picked up and trigger input. Try with 10k or 4k7 resistor from +3,3V to GPIO (at module side, not at switch side).
If you experience very high noise (like high voltage spikes) then a zener diode in parralel from gpio to gnd perhaps wouldn’t be a bad idea either. I mean - if your first pin is dead then it probably die from high voltage spike, picked up by long wire. Zener should have a value a bit above power supply value, say 3.6V, even a bit higher wouldn’t hurt - up to 5V, just to eliminate possible spikes.

Thanks, @Protoncek . I suspected that was the issue after the second GPIO failed. I hope the unit survives until I get a chance to pull it out of the garage ceiling to add the necessary components.