Reed switch connected to an ESP32: damaged bus?

I have been using a reed switch connected to pin GPIO39 of a Wemos S2 Mini ESP32, functioning as a door sensor for a garage side entrance. It is this kind of reed switch:

Reed switch

This the Yaml code for the sensor:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO39
      mode:
        input: true
        pullup: true
    name: ${friendly_name} Door contact
    device_class: door

This has been working fine for at least half a year or so.
But since a few days the door sensor was broken somehow: while the door was closed the sensor was showing the door to be open but intermittently changing status open/closed.
Troubleshooting learned that the reed switch itself, the wiring soldering joints and the cabling are still perfectly fine, so it looks like this problem is being caused by the ESP unit itself.
The reed switch was connected to the GPIO39 and GND pins, with no external pull-up resistor, but using the ESP internal pull-up resistor only.
When I changed the door sensor to the GPIO18 and GND pins, that appeared to be working fine again.
But when I again added a binary_sensor to the GPIO39 pin the problem was back again for that pin. And even without the reed switch being connected at all to the ESP the Door sensor status was changing frequently when configured for the GPIO39 pin.
This are some samples from a log:

[21:14:53][D][binary_sensor:036]: 'S2V10-01 Door contact': Sending state ON
[21:14:53][D][binary_sensor:036]: 'S2V10-01 Door contact': Sending state OFF
[21:15:03][D][binary_sensor:036]: 'S2V10-01 Door contact': Sending state ON
[21:15:03][D][binary_sensor:036]: 'S2V10-01 Door contact': Sending state OFF
[21:15:14][D][binary_sensor:036]: 'S2V10-01 Door contact': Sending state ON
[21:15:14][D][binary_sensor:036]: 'S2V10-01 Door contact': Sending state OFF
[21:15:34][D][binary_sensor:036]: 'S2V10-01 Door contact': Sending state ON
[21:15:34][D][binary_sensor:036]: 'S2V10-01 Door contact': Sending state OFF
[21:15:34][D][binary_sensor:036]: 'S2V10-01 Door contact': Sending state ON
[21:15:34][D][binary_sensor:036]: 'S2V10-01 Door contact': Sending state OFF

The status was going to ON and then immediately to OFF again.
As a test, with the reed switch still disconnected, I then added a delayed_on filter to that sensor, and that appeared to solve the problem by then:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO39
      mode:
        input: true
        pullup: true
    name: ${friendly_name} Door contact
    device_class: door
    filters:
      - delayed_on: 100ms

However, some hours and reboots later this binary_sensor on pin GPIO39 is now not functioning at all anymore: the status stays at OFF (Closed) constantly, without anything connected to GPIO39.
As a test I then also added a similar binary_sensor to GPIO40, again without connecting anything to this pin, and that sensor as expected gives a constant status of ON (Open):

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO18
      mode:
        input: true
        pullup: true
    name: ${friendly_name} Door contact
    device_class: door
    # filters:
      # - delayed_on: 100ms
  - platform: gpio
    pin:
      number: GPIO39
      mode:
        input: true
        pullup: true
    name: ${friendly_name} Door Test GPIO39
    device_class: door
  - platform: gpio
    pin:
      number: GPIO40
      mode:
        input: true
        pullup: true
    name: ${friendly_name} Door Test GPIO40
    device_class: door

S2V10-01_DoorTest_20240918-1000

So it looks like the GPIO39 bus functioning is broken somehow, initially causing a kind of internal debouncing, and then dying completely? Is that possible in silicon?
Being a security feature that has to be tamper proof, this type of reed switch is a normally open switch, which means that when the door is closed the switch is closed and a small current is flowing through it.
And since the door is closed most of the time, this current is flowing most of the time.
According to the Datasheet the ESP32-S2 has 45 kΩ pull-up resistors internally, so with a voltage of 3.3 V this current is 73 µA.
So can it be that this almost constantly flowing small current has damaged this ESP bus?

Or is there another possible cause for this problem?
ESP’s being rather cheap devices, can this be seen as normal degradation?
Can it be a bad surface mount soldering of the ESP chip on the PCB?

Any ideas about a possible cause and suggestions to improve this set-up?
As far as I can find it, this is not recommended anywhere in the online write-ups about reed switches, but should I add an external pull-up resistor, and if so, which resistance value?

The fault is likely mechanical - replace the reed switch.

Even though the contacts are encased in a glass vial, they do fail. The symptoms I’ve seen are reduced sensitivity (not switching unless the magnet is close), then more contact bouncing (odd switching), then intermittent switching.

I’ve had door switches fail with high resistance (e.g. 100R, not 2R).

Thanks, but like I wrote, the reed switch is still fine: it is functioning perfectly now on GPIO18.
And the problem occurred even when there was no reed switch connected at all.
So it must be the ESP itself I would say.

The only cause I can think of of a GPIO to fail (beyond crap solder) is ESD - although if the external cabling to the sensor is longer than 100mm, I’d not rely on the internal pull-up resistor and add something like a 10k at least. A noise cap (>=100nF to ground) might also help.

Probably not. Maybe abusing that Gpio precedently with 5V? Wiring sensor parallel to power wires?