We had a VW transporter van for our business years ago, and we had a similar problem. We went to several garages including 3 main dealers over 7 months trying to fix it. Almost all of them tinkered with the timing, to the point that it was so far out of place we couldn't get it to run at all in the end. Then a mate of mine decided to take the fuel tank off. In there we found a tiny piece of foil, we think the inner part of a cap seal from Redex or something like that, that every so often would be sucked up to the pipe at the end of the fuel tank, get stuck there. stop the fuel flow ands cut out the engine.
Of course, once the engine stopped and the pump stopped trying to suck fuel through, the bit of foil would drop down to the bottom of the tank and (apart from the fact that by now the timing was screwed) it ran fine again. So what should have been a 20 minute, more or less free fix had cost us over £2k and we never got it running right again after that.
So - what I'm saying is it definitely sounds like a blockage, possibly something the filter is picking up that's loose in the system, than then floats away again when the engine stops and it settles down. It could be something different of course, but your symptoms are identical to the letter to what was happening to our VW.