Virtual MIDI ports disappearing on Mac

My virtual MIDI ports are disappearing on macOS when one of my physical MIDI devices is turned off. I’m guessing it’s a buggy driver / USB implementation is crashing macOS’s MIDI implementation.

If I call MidiInput::getAvailableDevices() the name and id of all devices is error.

I’m guessing I can’t fix this problem, but is there anyway to get a notification that the MIDI system has restarted and I need to recreate my MIDI ports?