I've got the same problem on my Surface Book (1st gen) and a dock connected to an external monitor, ethernet, and sometimes a removable hard drive. The constant disconnect and reconnect started after I installed an insider build of Windows 10 in the fast ring a few months ago. Like some (or maybe all) users in this thread, I can see a "surface dock integration" and USB devices appearing and disappearing frequently in the device manager.
I believe this is a software issue and after suffering so long days I decided to do a system fresh install. I downloaded the original factory image from MS support site and installed it on my surface book using a flash drive, then upgraded to the latest Windows 10 ver 2004. The dock has since been working without any issue.
Maybe this is not the best solution, but for those who's considering ordering a $200+ dock 2, perhaps you might want to try this. It won't take long. Just back up your files or necessary apps (this is IMPORTANT) and do a clean OS reinstallation.
Hope this helps~
(BTW I did try the restore to factory option in the setting app, it did not help with the dock problem, although it has deleted all my personal files and apps. I think it still kept some wrong drivers or configurations or anything that caused the frequent dock disconnection. I'd suggest you do the same as I did, download the factory image from MS site and do a manual factory restoration.)