Several years ago, people would periodically post the same problem.
MANY people thought it was the filter that caused the problem.
Lots of discussion went on about size of filter, hole size in the nipples etc......
Some measured fuel flow thru various filters to prove the concern....
At the time, I had a filter (small/inline) and never had a problem....
Then on one ride, my bike did the same thing (after I installed a new Fuel Filter).
Started loosing power and eventually died.
I did the same as everyone, opened the gas cap, griped, wigled wires/tubing, etc......
I discovered that after setting a few minutes it would crank and go again....
Would even go WOT for extended periods with no problem... (Fuel flow thru the small filter had to be adequate to do this)
But after extended cruising, it would start the loosing power/dying cycle again...
When I posted it, most said my filter was too small and I should get a bigger fuel filter....
A few suspected vapor lock.....
But I wasn't convinced and decided that a bent (but still flowing) fuel line might be kinking after it got hot.
So, I put a section of curved Stainless Steel tubing where the bend was in my fuel line.
Problem solved.....
In my case, I used the tubing, some have used the spring. "Either works".
Ride safe, Ted